-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Zlib reserving twice the needed memory for inflate and inflateSync, kept in RSS until process exits. #44750
Comments
|
Hi devsnek. You're correct it's not a leak. I've changed the title and description. But something it is doing is reserving twice the memory needed, which for big images it can be huge and that's causing OOM kills in some scenarios on our containers. |
I don't understand what you meant about buffers in scope. Their refs are nulled before GC.
|
Just tried with an image double the size and RSS also reserves double (6.5GB on inflate, then keeps 3.2GB in RSS) |
Ok, this issue was founded on my misunderstanding and misconception of the inner workings of the buffering. So it makes sense it temporarily reserves double the size. It might be a good idea to mention it in the docs that it takes 2x. I'm closing the issue. Sorry for the troubles! |
Version
v18.9.0 and v16.16.0
Platform
Linux 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
zlib
What steps will reproduce the bug?
In the following zip file it's a copy of this JS code and the binary file needed to consistently cause the issue.
IMPORTANT: Needs to be called with
node --expose-gc
inflate-leak.zip
How often does it reproduce? Is there a required condition?
Every time for the attached binary file.
What is the expected behavior?
Inflate reserving only the needed size (~1.6GB) instead of double (~3.2GB).
RSS lowered reflecting array buffers/external lowered size after garbage collection.
What do you see instead?
After inflate or inflateSync RSS stays with an extra 1666MB
Additional information
The binary file is the deflated data chunk of a 400 mega pixel PNG
The text was updated successfully, but these errors were encountered: