When generating KeyString keys we use the KeyString::PooledBuilder that places multiple temporary KeyString on the same larger memory block to avoid multiple small allocations. Each KeyString holds a reference to the underlying memory that will not be free'd until all KeyString that is using it has been free'd.
Normally this is fine as these KeyString are passed to the sorter that spills do disk when the memory consumption reach a certain threshold. As this process clears all temporary KeyString instances all memory blocks should be free'd.
However, when there are multiple indexes being built at the same time these pooled memory blocks can be shared between KeyString instances belonging to different indexes. If some indexes generate large keys and need to be flushed to disk often the actual memory will not be free'd if there is still an index building that hasn't needed to spill to disk.
- is caused by
-
SERVER-47001 Reduce number of small buffer allocations for index builds
- Closed