Mystery memory consumption

68 views
Skip to first unread message

Roy Barkas

unread,
Sep 17, 2014, 8:04:16 AM9/17/14
to nod...@googlegroups.com
A question about node memory management.  I have (see below) a very simple bit of code that, when run, slowly increases it's RSS usage forever.

I've tried setting variable to null and deleting variables - no effect.
Adding or removing the nextTick has no effect.

It just sits there, running and slowly eating RSS.  heapUsed goes up and down as garbage collection occurs.

Am I missing the point somewhere?  why would  asimple program like this start with an RSS of 8-9 MB and over the course of 5 minutes have the RSS grow to 12.5MB and continue to grow from there?

var memInfo = {
    rss
: 0,
    heapTotal
: 0,
    heapUsed
: 0
}

var timer = setInterval(function () {
    process
.nextTick(function () {
       
var mem = process.memoryUsage();
       
if (mem.rss > memInfo.rss) {
            memInfo
.rss = mem.rss;
       
}
       
if (mem.heapTotal > memInfo.heapTotal) {
            memInfo
.heapTotal = mem.heapTotal;
       
}
       
if (mem.heapUsed > memInfo.heapUsed) {
            memInfo
.heapUsed = mem.heapUsed;
       
}

        console
.log('Latest', process.memoryUsage());
        console
.log('Max   ', memInfo);
   
});
}, 1000);



Luca Morandini

unread,
Sep 22, 2014, 5:02:56 AM9/22/14
to nod...@googlegroups.com
On 17/09/14 22:04, Roy Barkas wrote:
> A question about node memory management. I have (see below) a very simple bit of
> code that, when run, slowly increases it's RSS usage forever.

Forever ? In my experience RSS memory (mainly composed of buffers), gets released
eventually, but slowly, way more slowly than heap... and you cannot do anything
about it.

Regards,

Luca Morandini
Data Architect - AURIN project
Melbourne eResearch Group
Department of Computing and Information Systems
University of Melbourne
Tel. +61 03 903 58 380
Skype: lmorandini

Reply all
Reply to author
Forward
0 new messages