--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
On Mar 1, 12:15 am, Tim Caswell <t...@creationix.com> wrote:No it doesnt seem to let them go after the timeout has executed.
> Does it let them go after your function in the timeout is executed?
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
It turns out that V8 is able to GC the buffers you create - it just
never tries. You can observe this by adding the --trace-gc parameter
when you run node.
If you add some ongoing allocation, V8 will GC and collect the
unreferenced buffers, e.g. add this to the bottom of your benchmark
script:
setInterval(function(){
var b = new Buffer(1024*1024*100);
}, 500);
Smaller buffers will work too, but take longer to trigger GC.
This makes sense if you think about it - V8 may be assuming that
there's no point GCing when the total memory usage has remained the
same for awhile - especially since from the point of view of the V8
heap, only a few small objects have become collectible (which just
happen to be attached to big chunks of external memory.) Note that
reducing the delay on your 10 second timeout to e.g. 1 second also
solves the problem. I suspect your memory leak problem in your real
application may be unrelated to this behaviour.
This isn't really related, but it is very important for avoiding bugs:
you should never define an anonymous function inside a loop, since the
behaviour (as you can see with your gist) is unintuitive. Effectively
all variables (and anonymous functions) defined in a loop in
Javascript behave in the same way as if they were defined outside the
loop. I prefer to use the underscore.js library's iteration functions
instead for this reason.
Cheers,
Liam
On Mon, Feb 28, 2011 at 2:23 PM, mafintosh <mathi...@gmail.com> wrote:
--