I was running my server with pm2 start ... and pm2 monit was showing me 3GB memory after 2 hours. So I attached memwatch, now I waited for another 2 hours and again the memory shown by pm2 monit reached 3GB.
So, I checked the logs memwatch generated. Showed me:
{ before: { nodes: 75659, size_bytes: 11141702, size: '10.63 mb' },
after: { nodes: 73226, size_bytes: 10840598, size: '10.34 mb' },
change:
{ size_bytes: -301104,
size: '-294.05 kb',
freed_nodes: 5141,
allocated_nodes: 2708,
And another:
{ before: { nodes: 72591, size_bytes: 10728318, size: '10.23 mb' },
after: { nodes: 73284, size_bytes: 10798062, size: '10.3 mb' },
change:
{ size_bytes: 69744,
size: '68.11 kb',
freed_nodes: 5931,
allocated_nodes: 6620,
Now I am really confused, those are the last logs so I'm pretty sure those are the logs generated when pm2 monit showed the huge memory leak.
So, why is memwatch showing me 10MB+ memory and pm2 monit showing 3GB+?
Now switching to something like forever or monit to see if the leak still exists.
A bit more background
- I have been trying to profile and find the leak and there isn't just any leak showing on the profiles.
- The memwatch diff is started when a client connects and the difference is taken when the client disconnects.