$ node --expose-gc server.js
in another terminal:
$ curl localhost:5001
output in first terminal shows that req.foo
is still sitting in the heap:
{ before:
{ nodes: 27143,
time: Wed Mar 05 2014 13:59:20 GMT-0800 (PST),
size_bytes: 4595904,
size: '4.38 mb' },
after:
{ nodes: 25238,
time: Wed Mar 05 2014 13:59:25 GMT-0800 (PST),
size_bytes: 84183520,
size: '80.28 mb' },
change:
{ size_bytes: 79587616,
size: '75.9 mb',
freed_nodes: 3430,
allocated_nodes: 1525,
details:
[ [Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object] ] } }
hmmm i actually don't think is a problem. i read somewhere that v8 doesn't actually
gc()
until it starts running out of memory, so unless node is beginning to use a lot of memory, you won't see automatic garbage collection. thus, manuallygc()
ing multiple times solves the issue.a real test should be whether the process dies when you continuously hit it with requests.