2
votes

I have a memory leak on my nodejs application. In order to resume the purpose of the application, it's an api called by an iOS application and a backoffice to administrate some content. The application is in production and we experience some memory leak due to utilisation.

The memory on the server is always going up and never going down. I try to analyze the problem using node-heapdump.

First of all, i see a big difference between the heap size of the snapshot given by node-heapdump and the size taken by the app in the memory (heap size ~ 30Mb and RAM size ~ 100Mb), where that difference came from ?

Then i see an increment of the heap size just by refreshing a home page who does not return anything. Is anyone has an idea of where my problem could be ?

For information i use nodejs version 0.10.x and expressjs 4.0.0

Thanks in advance guys.

EDIT

I install memwatch-next and the leak event is raised. The error i have is this one :

warning: possible EventEmitter memory leak detected. 11 leak listeners added. Use emitter.setMaxListeners() to increase limit.

I try to set the defaultMaxListeners but when i stress the application the leak event is raised after sometime. Does anyone knows what that error means ?

4
A home page that does not return anything? - Spork
For anything i mean not a json result or thing like that. So it's not because of a new memory allocation for an object that the memory went up. - Martin Stievenart

4 Answers

2
votes

have a look at memwatch-next

I had similar issues with the memwatch package and switched to memwatch-next and it installed without the node-gyp error and produced worked. As for the difference between the RSS and the heapdump , I am in the same boat as you are.

0
votes

Try to find memory leakage leak and stat from https://www.npmjs.com/package/memwatch.

Hope it would help.

0
votes

I think you need this tool: easy-monitor

0
votes

Might I recommend you try running the application with the --inspect argument, this will then allow you to attach Chrome dev tools and take memory snapshots. From here take one at startup one during testing and then one after you have finished testing the application (no more requests to the application but must still be running.) This will allow you to see what exactly is causing the growth in memory.

From here you will be able to see what is causing the growth and hopefully an indication as to where the leak is.