-
Notifications
You must be signed in to change notification settings - Fork 31.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
RSS growing into several hundreds of megabytes and never going down in size in any significant way when no activity is being served. #56641
Comments
What memory allocator are you using? Have you tried using a memory allocator that prioritizes low RSS, like jemalloc? (Not sure if |
This is running on FreeBSD (amd64 compatible CPU).
|
Are you able to reproduce it on other platforms or is it just FreeBSD? |
I have never tested it on any other platform. |
Is your question: is that normal? Yes. JS is a GC language and V8's GC is memory hungry by default. There are several flags for enforcing size limits on the JS heap. I'll go ahead and close this because AFAICT a) it's working as intended, and b) there's no indication of an actual memory leak. |
OK. Thank you for clearing that out. |
Version
18.20.4
Platform
Subsystem
No response
What steps will reproduce the bug?
I would like to ask if following behaviour of RSS part of memory of node process
is within a norm. Or is this an abnormal behaviour caused by memory leaks in some ibraries.
It's hard to judge based on valgrind, as it producess several dozens of thousands of lines of log
covering several libraries after termination of server.js process by Ctrl-C.
mkdir certs
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -keyout certs/cert.key -out certs/cert.pem
node server.js
run several instances of at the same time
node client
RSS starts to grow into region of several hundred of megabytes when multiple instances of cliet.js are connecting to it.
No substantial decrease of size of RSS reported by server.js been observed
in time period of up to one hour. It decreased only by few dozens of megabytes
shortly after connections stopped but remained elevated into many hundreds
of megabytes region.
It's unclear if that memory would ever be available to the OS in case on need for memory by other processes. There are many environments with limited resources where node holding right to big areas of memory without actual need to hold it for prolonged periods of time could cause problems and starve other processes of needed memory. This is why some people could find it concerning.
After terminating (Ctrl+C) server.js running as result of
valgrind --leak-check=full --show-leak-kinds=all node server.js
Few dozens of thousands of lines is being generated covering many libraries.
Very last lines of them are following
==79512==
==79512== LEAK SUMMARY:
==79512== definitely lost: 0 bytes in 0 blocks
==79512== indirectly lost: 0 bytes in 0 blocks
==79512== possibly lost: 0 bytes in 0 blocks
==79512== still reachable: 5,348,193 bytes in 23,822 blocks
==79512== suppressed: 12,556 bytes in 37 blocks
==79512==
==79512== Use --track-origins=yes to see where uninitialised values come from
==79512== For lists of detected and suppressed errors, rerun with: -s
==79512== ERROR SUMMARY: 24 errors from 12 contexts (suppressed: 0 from 0)
At this point I'm not sure if adding full log would be of any help as it's szie
reached over 3 megabytes.
Files below:
server.js
client.js
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
Expected behavior: Passing control over unused memory back to the OS.
Rationale: There are many environments with limited resources where node holding right to big areas of memory without actual need to hold it for prolonged periods of time could cause problems and starve other processes of needed memory. This is why some people could find it concerning.
What do you see instead?
RSS growing into hundreds of megabytes and never decreasing significantly even after very long time.
Additional information
No response
The text was updated successfully, but these errors were encountered: