-
Notifications
You must be signed in to change notification settings - Fork 174
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
Too high memory consumption #334
Comments
Interesting - so if I want to try and reproduce this, I can basically create a program that runs a number of threads in pairs where each pair has one thread allocating memory and the other then deallocating it? What are the memory sizes being allocated? |
That's the core of payload of may application, but small other allocations (from other threads, or other sizes may increase this behavior as far as I know). Allocations that are performed a lot (99.9% of number of allocations): 256, 512 and 4096, there may be few in range of 4 KiB-60 KiB, but these are sparse. P.S.: |
Now I think I have tested enough with Is it normal for rpmalloc to consume (reserve/cache) a lot more memory than needed? 'main |
Hi,
I have written a program, that works in a producer-consumer allocation scheme (there are other threads as well, but most of the work and allocation is done in main producer-consumer pair of threads). Initially I used glibc malloc, but it was very slow, then I've found rpmalloc which in my case sped up performance of my program about 5 times. There is one problem: there is a constant increase in memory consumption. This shocked me, because my program works in iterations and after each iteration most of allocated memory is being freed.
Over time of running program, resident memory and virtual memory both increased a lot each minute. After some time, the program crashed having over 1.5 TiB of virtual memory allocated, 15 GiB in ram and 40 GiB in swap. The data stored in swap was never loaded back into ram (disk usage showed only writes). Total number of calls to pair of
rpmalloc
andrpfree
was around 140 bilion, with most of allocations of size 256, 512 and 4096.In contrast, glibc malloc version used in peak up to 9 GiB of RAM and custom object pool used in peak up to 6 GiB of RAM having done the same amount of work as rpmalloc version.
My system:
OS: Arch Linux x86_64
Kernel: 6.8.9-arch1-2
RAM: 32GiB
SWAP: 44 GiB
rpmalloc version:
branch: develop
commit: 955f44b
Behavior of branch mjansson/rewrite 2dd697f seems to exhibit the same behavior.
I am not sure if this is a problem with my application or rpmalloc, but other allocators do not indicate any faulty behavior. Valgrind and GCC's AddressSanitizer do not show any memory leaks, buffer overflows, nor hidden segmentation faults in any of the following versions: rpmalloc, malloc, or custom object pool.
Edit:
I've found out that
malloc
overly high resident memory usage is due to linux settings and I can callmalloc_trim(0)
to decommit/free resident memory (as far as I've found out, other systems do not have nor requiremalloc_trim
).I should also note that I compile rpmalloc with
ENABLE_OVERRIDE=0
, because I had strange errors while debugging otherwise.The text was updated successfully, but these errors were encountered: