Return correct usable_size for BlockContents (#4246)

Summary:
If jemalloc is disabled or the API is incorrectly referenced (jemalloc api on windows have a prefix je_) memory usage is incorrectly reported for all block sizes. This is because sizeof(char) is always 1. sizeof() is calculated at compile time and *(char*) is char. The patch uses the size of the slice to fix that.
Fixes #4245
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4246

Differential Revision: D9233958

Pulled By: maysamyabandeh

fbshipit-source-id: 9646933b24504e2814c7379f06a31148829c6b4e
This commit is contained in:
Maysam Yabandeh 2018-08-08 17:40:05 -07:00
parent f9fc1f483a
commit 9810a21baa

View File

@ -212,7 +212,7 @@ struct BlockContents {
#ifdef ROCKSDB_MALLOC_USABLE_SIZE #ifdef ROCKSDB_MALLOC_USABLE_SIZE
return malloc_usable_size(allocation.get()); return malloc_usable_size(allocation.get());
#else #else
return sizeof(*allocation.get()); return data.size();
#endif // ROCKSDB_MALLOC_USABLE_SIZE #endif // ROCKSDB_MALLOC_USABLE_SIZE
} else { } else {
return 0; // no extra memory is occupied by the data return 0; // no extra memory is occupied by the data