-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Memory usage spikes with source maps (--enable-source-maps
) from v18.10.0 onwards
#46140
Comments
--enable-source-maps
) from v18.11.0--enable-source-maps
) from v18.11.0 onwards
The difference looks rather insignificant. I don't think you can say marginally higher memory usage indicates a memory leak. It might, but it probably isn't. Is this a problem for you somehow or just something you noticed? |
Yes, memory leak might be a bit harsh but on a project I work on, memory usage spikes by about 150MB whenever an error is handled by the application. When that application is run in a container on Kubernetes, whenever an error is handled, the container instantly hits its memory limit and is restarted by K8s. So it's rather serious and blocking upgrading to newer versions. The application's code is bundled into a single JS file, with only a few external dependencies, so stack traces aren't crazy long. It appears there might be an underlying issue in v18.11.0, it was just hard to prove with a minimal reproduction. |
That's pretty severe. How does pre-v18.11.0 compare? No spike, or spiky but not as extreme? How big are the source maps? |
The app is currently running on v18.9.1 and there's no spike there -- memory consumption when an error is handled is just slightly larger than for the no-error scenario.
App script: main.js -> 9.7MB |
Can you test with v18.10.0? I don't think there are any changes between v18.10.0 and v18.11.0 that could explain such a jump but between v18.9.1 and v18.10.0 there's at least a2eb55a. |
I think you might be on to something:
I ran rudimentary tests and got these numbers from It's interesting that my minimal reproduction (original post) didn't show spikes on 18.10.0! |
@alan-agius4 @aduh95 @legendecas a2eb55a seems to cause excessive memory use. I can't tell if the commit introduced it, or if the issue was already present but latent. You should chime in. :-) |
--enable-source-maps
) from v18.11.0 onwards--enable-source-maps
) from v18.10.0 onwards
--enable-source-maps
) from v18.10.0 onwards--enable-source-maps
) from v18.10.0 onwards
Thanks for reporting! I'll create a large JS file with about source map of 10M+ size to verify this issue. |
I think this issue was marked as completed by mistake. |
The backport of the fix was blocked on other changes not backporting cleanly but that's been resolved now. I've pinged @juanarbol about it. |
Version
18.10.0
Platform
5.4.0-135-generic #152-Ubuntu SMP Wed Nov 23 20:19:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
UPDATE: The steps below attempt to create a minimal reproduction of the issue, rather unsuccessfully, since the issue seems to be caused by large source maps and not merely throwing/handing an error. See #46140 (comment) for more info.
Obsolete minimal reproduction
Copy the following code blocks and save them as
main.js
andmain.js.map
and then runnode --enable-source-maps main.js
:main.js
:main.js.map
:On my machine, NodeJS v18.11.0 produces:
While NodeJS v18.10.0 produces:
When an error is thrown, the increase in memory usage on v18.11.0 spikes a bit higher than on v18.10.0. The same behaviour can be observed in later versions after v18.11.0.
For reference, without
--enable-source-maps
, this is the output on v18.11.0:And on v18.10.0:
How often does it reproduce? Is there a required condition?
It's consistent.
What is the expected behavior?
That memory usage doesn't spike when an error is handled by the application.
What do you see instead?
Memory usage spikes (ref: #46140 (comment)).
Additional information
No response
The text was updated successfully, but these errors were encountered: