Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroying a readStream for a compressed entry may cause a memory leak #27

Closed
thejoshwolfe opened this issue Dec 31, 2015 · 1 comment
Closed
Labels

Comments

@thejoshwolfe
Copy link
Owner

I'm not actually sure this is a problem, but I think it is. The zlib module appears to offer no way of aborting an inflate stream in progress. Currently, yauzl just unpipes and abandons it hoping that the GC will do something helpful. But since there are C resources supporting the JavaScript API, this is probably causing a memory leak.

@thejoshwolfe thejoshwolfe changed the title destroying a readStream for a compressed entry causes a memory leak destroying a readStream for a compressed entry may cause a memory leak Jun 26, 2016
@thejoshwolfe
Copy link
Owner Author

I did some science on this, and I concluded that this is not an issue.

The default window size for zlib inflate is 32KB, and so the expected memory usage after triggering the possible memory leaky 1 million times is 32GB of ram.

I ran a test which repeatedly triggered the possible memory leak, and although the memory usage was much higher than I was expecting (1251M VIRT, ~160M RES, ~12K SHR), it stabilized quickly. After 1 million iterations of triggering the possible memory usage, the highest number in the memory usage was only ~1G, not 32G. I'm considering this issue resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant