From 9810a21baa7e196f298832d46a2e4a21b4b4f441 Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Wed, 8 Aug 2018 17:40:05 -0700 Subject: [PATCH] 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 --- table/format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/table/format.h b/table/format.h index 258d1a9e7..fd8459fdc 100644 --- a/table/format.h +++ b/table/format.h @@ -212,7 +212,7 @@ struct BlockContents { #ifdef ROCKSDB_MALLOC_USABLE_SIZE return malloc_usable_size(allocation.get()); #else - return sizeof(*allocation.get()); + return data.size(); #endif // ROCKSDB_MALLOC_USABLE_SIZE } else { return 0; // no extra memory is occupied by the data