http-server icon indicating copy to clipboard operation
http-server copied to clipboard

Memory leak on large files with streaming middleware union

Open zckevin opened this issue 9 years ago • 12 comments

I'm trying to serve large files(1 GiB) using http-server, the memory usage is abnormally high, so I got the heap profile and saw lots of 65535 KiB Buffer without being GCed.

smalloc smalloc2

But when I switch to connect instead of union, everything is all right then, so I'm pretty sure that something wrong is happening in union.

http-server v0.7.5 node v0.10.32

zckevin avatar Mar 17 '15 02:03 zckevin

I'm seeing the same thing here. Requesting/streaming a large file (ex: a movie) will make it consume Gbs of memory. If I request the same file again the memory usage will double. Doesn't seem to be released, in the end the node process is killed by the OS when it runs out of available memory.

stianeikeland avatar May 16 '15 14:05 stianeikeland

+1 I'm having the same issue when trying to transfer big files from devices with low-memory (like the Raspberry Pi).

Couldn't be related to this the issue? http://stackoverflow.com/questions/15001822/sending-large-image-data-over-http-in-node-js

roccomuso avatar Jan 05 '16 16:01 roccomuso

Pull request https://github.com/flatiron/union/pull/55, but seems this project is not maintained any more, a new dependency should be chosen.

zckevin avatar Jan 20 '16 13:01 zckevin

Yes. union is not maintained anymore on purpose since it predates streams2 in Node core. A PR that removes it would be welcome.

indexzero avatar Jan 21 '16 06:01 indexzero

@indexzero

union is not maintained anymore […]. A PR that removes it would be welcome.

I'd be happy to do this. One solution might be to just use Express for the middleware-like behavior. A more lightweight solution might be to used middl. What do you think?

derhuerst avatar Jul 30 '16 19:07 derhuerst

Problem persists on http-server 0.9.0 and node 6.7.0. Which is too bad, as otherwise this is a great little tool. Have to use HFS instead (http://www.rejetto.com/hfs/?f=dl). :( (For some reason HFS is faster as well, by about 20%.)

hdf avatar Oct 08 '16 13:10 hdf

This should be fixed with in [email protected]

jcrugzz avatar Oct 22 '16 18:10 jcrugzz

Is this confirmed fixed? Can this issue be closed?

thornjad avatar Oct 26 '18 10:10 thornjad

I just tried transferring a huge file after running http-server 0.11.1 with no special command-line arguments and the memory usage stayed reasonable throughout. I don't know whether this answers the question, since there is no example code in this ticket and I don't know if union is being used by default.

tremby avatar Oct 26 '18 20:10 tremby

union is still being used (though maybe it shouldn't be), but this issue looks to have been fixed with flatiron/union#54

thornjad avatar Oct 26 '18 20:10 thornjad

We will eventually be removing union (see #483), so hopefully this issue will go away.

thornjad avatar Apr 16 '19 16:04 thornjad

This issue has been inactive for 180 days

github-actions[bot] avatar Oct 16 '21 12:10 github-actions[bot]