1

My application is running on one Modulus servo with 512 MB of memory. A run of the app looks like this:

modulus metrics

As you can see, the memory rises during execution. But then it stays at 100% indefinitely, even if no further requests are made. I am concerned about the memory consumption of the app on repeated requests.

Is there something that I need to do in my Node.js/Express app to get memory consumption down again after a request finishes?

Currently, I only have this:

process.on("exit", function () {
    'use strict';
    if (mongoose && mongoose.connection) {
        mongoose.connection.close();
    }
});
reggie
  • 3,523
  • 14
  • 62
  • 97
  • The jump in memory coincides with a steep response time. Are you retrieving lots of data from MongoDB? If so, how exactly? – robertklep Aug 03 '15 at 14:46
  • Well, the spike and then staying there is perfectly explainable. When V8 allocates memory, it just keeps it indefinitely for performance reasons. Is this a problem for you? You might need more memory for what you're doing, but we couldn't tell you for sure since we have no idea what your application does. – Brad Aug 04 '15 at 20:34
  • I would note that this is a confusing graph. It has 2 axis. The CPU axis goes to 100%. The memory graph scales by the maximum amount consumed in the time window. So you are not actually using 100% of the memory, the 100% label only applies to CPU usage. – David Berger Aug 04 '15 at 20:23
  • I think you might be slightly colorblind. The graph has two shades of green, and it's definitely the memory line that is pegged to the top. – Brad Aug 04 '15 at 20:32

1 Answers1

1

I think you have memory leak.

Which version of Node.js you are using?

0.12 - Seems to consume more memory.

Check this answers for more,

Detecting memory leaks in nodejs

Tutorial -- https://github.com/felixge/node-memory-leak-tutorial

Community
  • 1
  • 1
Sathish
  • 2,056
  • 3
  • 26
  • 40