See this thread https://groups.google.com/forum/#!topic/nodejs/A8wbaaPmmBQ
And the correct way to pipe is something like here 
https://groups.google.com/forum/#!topic/nodejs/wtmIzV0lh8o

понедельник, 19 августа 2013 г., 22:44:00 UTC+4 пользователь Davis Ford 
написал:
>
> I have the following code (using node v0.10.0 and Express 3.3.5) which is 
> aimed at serving an mp3 audio file to an http client.  
>
> app.get('/media/:id/play', function (req, res) {
>
>   var file = findById(Number(req.params.id));
>   if (!file) { return res.send(404); }
>
>   res.writeHead(200, {
>     'Content-Type': 'audio/mpeg',
>     'Transfer-Encoding': 'chunked',
>     'Connection': 'close'
>   });
>
>   var readStream = fs.createReadStream(file.path);
>
>   res.on('unpipe', function () {
>     res.end();
>   });
>
>   readStream.pipe(res);
> });
>
> If I start the server and hit the URL in a browser it streams the audio 
> just fine.  If I kill the browser I can see that the server socket is 
> closed ($NODE_DEBUG=net,http) and the readStream fires the close event.
>
> However, if I open the url in a browser again, the memory on the node 
> process grows a couple MB each time, and never appears to get released.  I 
> have studied the API to try to ensure I'm cleaning up properly, but I don't 
> see anything I'm missing -- which is why I'm posting here.  What am I doing 
> wrong?
>
>

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