-
Notifications
You must be signed in to change notification settings - Fork 27.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
Long running memory leak problem #14227
Long running memory leak problem #14227
Conversation
Update README.md
Problem: The memory will slowly increase with the drawing until restarting. Observation: GC analysis shows that no occupation has occurred, so it is suspected to be a problem with the underlying allocator. Reason: Under Linux, glibc is used to allocate memory. glibc uses brk and mmap to allocate memory, and the memory allocated by brk cannot be released until the high-address memory is released. That is to say, if you apply for two pieces of memory A and B through brk, it is impossible to release A before B is released, and it is still occupied by the process. Check the suspected "memory leak" through TOP. So I replaced TCMalloc, but found that libtcmalloc_minimal could not find ptthread_Key_Create. After analysis, it was found that pthread was not entered during compilation.
needs comments and review from other linux users |
OK, thanks for the reply!! |
I'll merge it in into dev and if it breaks things for people we'll have to revert or fix it. |
This break tcmalloc usage on any current Linux systems, as pthread was merged back in glibc since glibc 2.34: So at least on current glibc, this change should be skipped. |
I actually did two things without changing the underlying logic. It has the logic of tcmalloc in it. It only adds a layer to determine whether the current library contains the libpthread library. The original logic remains unchanged, adding a library and a judgment.
|
For example, with glibc-2.38 here:
Also, I have not found any reports of issues with incorrectly linked libtcmalloc, this sounds like a local problem, or a bug in gperftools build system, which fix should rather be there than in user applications (https://github.com/gperftools/gperftools). Note it has some build logic to support pthread on several environments, so you should not force-add -lpthread and let the build system detect it (and most probably use "-pthread") |
fix prepare_tcmalloc (fix: #14227)(Fixed memory leak issue in Ubuntu 22.04 or modern linux environment)
Description
Problem: The memory will slowly increase with the drawing until restarting.
Observation: GC analysis shows that no occupation has occurred, so it is suspected to be a problem with the underlying allocator.
Reason: Under Linux, glibc is used to allocate memory. glibc uses brk and mmap to allocate memory, and the memory allocated by brk cannot be released until the high-address memory is released. That is to say, if you apply for two pieces of memory A and B through brk, it is impossible to release A before B is released, and it is still occupied by the process. Check the suspected "memory leak" through TOP.
So I replaced TCMalloc, but found that libtcmalloc_minimal could not find ptthread_Key_Create. After analysis, it was found that pthread was not entered during compilation.
As shown in the figure:
detail steps:
1、nm -D /lib64/libc.so.6 | grep -e pthread_key_create
2、nm -D /lib64/libpthread.so | grep -e pthread_key_create
3、ldd /usr/local/lib/libtcmalloc_minimal.so.4
4、 ldd /usr/local/lib/libtcmalloc.so.4
dependents:
1、gperftools-2.13 (gcc-c++: c++11)
2、libunwind-1.6.2
Screenshots/videos:
Checklist: