I'm monitoring my app and I've seen my memory usage increase really oddly (it did not decrease after X hours), so I suspected a leak. I've found out that the memory seems to remain uncollected when using fs.readStream. I made a small example with an http server that serving a 2mb file and did some ab (apache benchmark) load testing on it (ab -n 5000 -c 100 a couple of times). X minutes after the load testing is done, the memory idles at 480 Mb and doesn't drop.
http.createServer(function(req, res) {fs.createReadStream(fpath).pipe(res);
// run with: node --expose-gc loop.jsvar fs = require('fs');// 2 Mb filevar fpath = __dirname + '/sample.txt';function readStream() {fs.createReadStream(fpath).on('open', function() {process.stdout.write('o');}).on('data', function() {process.stdout.write('*');}).on('end', function() {process.stdout.write('$');});}for (var i = 0; i < 180; i++) {readStream();}function getMem(msg) {memUsg = (process.memoryUsage().rss / (1024 * 1024)).toFixed(2);console.log('[' + new Date() + '] rss: ' + memUsg + ' Mb');}var garbageCollect = gc || function() {};setInterval(function() {garbageCollect();getMem();}, 5000);
--
--
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 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?hl=en
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
--
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 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?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/uETidz1BUHk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.