Hello there,

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.

Am I missing something or is there really a problem with this?

index.js

var http   = require('http'),
     bytes = require('bytes'), // npm install bytes
     fs       = require('fs');                                              
                                                         
                                                                            
                                      
var fpath = '/path/to/a/2mb/file/in/my/case';
                                                                            
                                      
http.createServer(function(req, res) {                                     
                                       
  fs.createReadStream(fpath).pipe(res);                                     
                                      
}).listen(7777);                                                           
                                       
                                                                            
                                      
var lastMem;                                                               
                                       
                                                                            
                                      
function getMem(msg) {                                                     
                                       
  var memUsg;                                                               
                                      
                                                                            
                                      
  msg = msg || '';                                                         
                                       
                                                                            
                                      
  memUsg = bytes(process.memoryUsage().rss);                               
                                       
  if (lastMem !== memUsg) {                                                 
                                      
    lastMem = memUsg;                                                       
                                      
    console.log(msg + ' ' + memUsg);                                       
                                       
  }                                                                         
                                      
}                                                                           
                                      
                                                                            
                                      
setInterval(function() {                                                   
                                       
  getMem('rss:');                                                           
                                         
}, 5000);

Thanks!

-- 
-- 
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

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to