$ 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] ] } }
I have narrowed it down to this line
https://github.com/visionmedia/express/blob/master/lib/middleware/init.js#L16
If you comment that out, memory is ok (this is an issue on express 3 and 4) and a very good find.
/cc @jonathanong @visionmedia