On Tue, Apr 10, 2012 at 16:43, Romain <[email protected]> wrote:
> Hi,
>
> I am struggling to understand why NodeJs do not decrease the resident memory
> after a lot of console.log.
>
> If someone could explain me this behaviour I would be very happy.
>
>     for (var i = 0; i< 100 * 1000; i++){
>       console.log(i);
>     }
>
>     setTimeout(function(){ console.log('END') }, 10000000);
>
> The last setTimeout is used to keep nodejs running, so gc happens when node
> is idle.

This question has been asked in various forms on both the mailing list
and the bug tracker (and probably SO as well).

Each console.log() statement allocates some memory that is not
reclaimed until the next tick of the event loop. If you slice up the
loop with process.nextTick() into 100 or 1000 segments, memory usage
will be much more constant.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to