Description
I am investigating a memory leak in one project and suspect that it might be caused by lmdb-store
somehow.
The leak is not happening in v8 - it occurs somewhere in native C++ code (I see big RSS values with normal Total V8 Heap values).
Also, I realize that when dealing with LMDB we should check for "dirty" pages only. I do not rely on RSS readings alone - using pmap -x
to monitor the actual "dirty" memory of the Node process.
So, I am sampling memory in Node and see the following results:
heap total: 903 MB; external: 923 MB (buffers: 920 MB)
Up to a point heapTotal + external
matches pretty closely dirty
value returned by pmap
. But then at some point, I see this:
heap total: 1.0 GB; external: 173 MB (buffers: 166 MB)
So essentially Node releases 750MB of buffers but dirty
value from pmap
doesn't change. RSS doesn't change as well. Eventually the process OOMs.
My best guess is that those allocated buffers are somehow retained in lmdb-store
but I may be completely missing something. I didn't investigate memory leaks in native code before, so not sure what would be the next step to confirm or discard this hypothesis.
Do you think it is possible?
P.S. some context: the code causing those allocations does long-living cursor iterations (may traverse 100,000+ items) with corresponding gets
. Also, this mostly happens in a sync manner (sadly parts of the code are in the user-land and we don't have control over it).