Node: Node old space memory leak

Created on 2 Mar 2018  路  4Comments  路  Source: nodejs/node

  • Version: v8.7.0
  • Platform: Linux 3.16.0-4 64-bit
  • Subsystem:

Hello,

I have encountered memory issues with node applications running in a production environment. There seems to be some kind of memory leak related to node and v8 garbage collection.

I have collected memory statistics from Linux proc-fs /proc/x/status VmRSS property and from node with process.memoryUsage() and v8.getHeapSpaceStatistics(). When plotting these metrics I see some very strange behaviour.

2018-03-02-155522_1832x889_scrot
2018-03-02-161056_1835x893_scrot

The sawtooth looking memory usage appears on several different node programs running independently on the same server and when the peaks line up it causes OOM issues.

Why is it that old_space_size is growing but old_space usage is not? And why does the total memory footprint increase while old space size does not increase?

The node process in the graph is a simple mqtt broker using mosca och mongoose for mongodb access. The amount of messages received in the module does not account for the large increase in memory usage. When the module is restarted it does not start spiking instantly, it will usually take a couple hours until it starts behaving strangely.

Sincerely
Daniel

V8 Engine memory question

Most helpful comment

I actually talked about this memory leak in Node 8.7.0 during my Node Interactive talk on memory leaks :).

This is fixed. Please upgrade to the latest 8.x.

All 4 comments

cc @nodejs/v8 Anyone aware of similar issues/fixes in the upstream?

It's probably going to be hard to answer the question without a reproducible test case, but you might want to use the V8 sampling heap profiler to find out the problematic JS code path. There is an addon that helps you dump the profile programmatically in production, see https://github.com/v8/sampling-heap-profiler

I actually talked about this memory leak in Node 8.7.0 during my Node Interactive talk on memory leaks :).

This is fixed. Please upgrade to the latest 8.x.

If you still see leaks after upgrade, please do reply here, and I'll reopen the issue.

Upgrading to Node 8.9.4 solved the issue. Thank you

Was this page helpful?
0 / 5 - 0 ratings