Martin Stievenart
Martin Stievenart

Reputation: 295

Memory leak node js

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 ?

Upvotes: 2

Views: 1297

Answers (4)

Starystars67
Starystars67

Reputation: 13

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.

Upvotes: 0

hyj1991
hyj1991

Reputation: 1

I think you need this tool: easy-monitor

Upvotes: 0

Glenn Hinks
Glenn Hinks

Reputation: 248

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.

Upvotes: 2

kj007
kj007

Reputation: 6254

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

Hope it would help.

Upvotes: 0

Related Questions