|
|
|
|
|
by FooBarWidget
463 days ago
|
|
I did research into the glibc memory allocator. Turns out this is not memory fragmentation, but per-thread caches that are never freed back to the kernel! A free() call does not actually free the memory externally unless in exceptional circumstances. The more threads and CPU cores you have, the worse this problem becomes. One easy solution is setting the "magic" environment variable MALLOC_ARENA_MAX=2, which limits the number of caches. Another solution is having the application call malloc_trim() regularly, which purges the caches. But this requires application source changes. https://www.joyfulbikeshedding.com/blog/2019-03-14-what-caus... |
|