Find Memory Leak on Node.js / Express.js Application
<p>I have an Express.js web app which is constantly breaking because of memory problems:</p>

<pre><code>FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap
out of memory
</code></pre>

<p>When I start the service, the memory usage is about 170Mb (reported by htop as RES memory). Then I start throwing request at it, and the memory start rising.
I'm using <code>memwatch</code> to try to track the problem in what looks like a memory leak, but a <code>memwatch.HeapDiff()</code> reports something like:</p>

<pre><code>{ before: { nodes: 2093729, size_bytes: 197165296, size: '188.03 mb' },
  after: { nodes: 2491264, size_bytes: 232097040, size: '221.34 mb' },
  ...
</code></pre>

<p>... where I understand that the app is using 221.34mb for the heap; but with <code>htop</code> the memory usage is about 2GB when it breaks. </p>

<p>The question is, if my assumptions are right, what could be using non-heap memory that is still reported by htop as RES memory? </p>