Skip to content

Commit 0461349

Browse files
louiswilliamsevergreen
authored andcommitted
SERVER-42931 KeyString::Value should report its memory usage as the total buffer capacity
1 parent 00e2bca commit 0461349

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/mongo/db/storage/key_string.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ class Value {
376376
}
377377

378378
int memUsageForSorter() const {
379-
return sizeof(Value) + _bufSize;
379+
// Use buffer capacity as a more accurate measure of memory usage.
380+
return sizeof(Value) + _buffer.capacity();
380381
}
381382
/// Members for Sorter
382383

src/mongo/util/shared_buffer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ class ConstSharedBuffer {
212212
return _buffer.isShared();
213213
}
214214

215+
size_t capacity() const {
216+
return _buffer.capacity();
217+
}
218+
215219
/**
216220
* Converts to a mutable SharedBuffer.
217221
* This is only legal to call if you have exclusive access to the underlying buffer.

0 commit comments

Comments
 (0)