diff --git a/src/object.c b/src/object.c index b8200dd815..79d4b62cad 100644 --- a/src/object.c +++ b/src/object.c @@ -1202,7 +1202,7 @@ size_t objectComputeSize(robj *key, robj *o, size_t sample_size, int dbid) { asize = sizeof(*o) + hashtableMemUsage(ht); while (hashtableNext(&iter, &next) && samples < sample_size) { - elesize += hashTypeEntryAllocSize(next); + elesize += hashTypeEntryMemUsage(next); samples++; } hashtableResetIterator(&iter); diff --git a/src/server.h b/src/server.h index 3afa6fdb24..745fb5e0b4 100644 --- a/src/server.h +++ b/src/server.h @@ -3237,7 +3237,7 @@ typedef void hashTypeEntry; hashTypeEntry *hashTypeCreateEntry(sds field, sds value); sds hashTypeEntryGetField(const hashTypeEntry *entry); sds hashTypeEntryGetValue(const hashTypeEntry *entry); -size_t hashTypeEntryAllocSize(hashTypeEntry *entry); +size_t hashTypeEntryMemUsage(hashTypeEntry *entry); hashTypeEntry *hashTypeEntryDefrag(hashTypeEntry *entry, void *(*defragfn)(void *), sds (*sdsdefragfn)(sds)); void dismissHashTypeEntry(hashTypeEntry *entry); void freeHashTypeEntry(hashTypeEntry *entry); diff --git a/src/t_hash.c b/src/t_hash.c index b0ba8f319c..4fcb116729 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -220,9 +220,9 @@ static hashTypeEntry *hashTypeEntryReplaceValue(hashTypeEntry *entry, sds value) } } -/* Returns allocation size of hashTypeEntry and data owned by hashTypeEntry, - * even if not embedded in the same allocation. */ -size_t hashTypeEntryAllocSize(hashTypeEntry *entry) { +/* Returns memory usage of a hashTypeEntry, including all allocations owned by + * the hashTypeEntry. */ +size_t hashTypeEntryMemUsage(hashTypeEntry *entry) { switch (entryGetEncoding(entry)) { case ENTRY_ENC_EMB_VALUE: return zmalloc_usable_size(sdsAllocPtr(entry));