From 38e05a18e716da5020d8f01f37e8bd8cf8f769b1 Mon Sep 17 00:00:00 2001 From: Eric Milkie Date: Mon, 23 Dec 2019 22:59:34 +0000 Subject: SERVER-44964 calculate index build memory usage per key based on BSONObj buffer capacity instead of object size --- src/mongo/bson/bsonobj.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mongo/bson/bsonobj.h') diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h index 5f50271e4c7..f5d5670223e 100644 --- a/src/mongo/bson/bsonobj.h +++ b/src/mongo/bson/bsonobj.h @@ -574,8 +574,8 @@ public: return BSONObj(static_cast(ptr)); } int memUsageForSorter() const { - // TODO consider ownedness? - return sizeof(BSONObj) + objsize(); + const auto ownedSize = isOwned() ? _ownedBuffer.capacity() : 0; + return sizeof(BSONObj) + ownedSize; } private: -- cgit v1.2.1