![]() Newer versions of free seem to have code that executes internal systrim function that should trim top of the arena, but I wasn't able to make it work. It says there that free never returns memory back to the kernel, unless malloc_trim is called. I have found this old (2006) ticket on glibc's bugzilla. Try using another allocator that might take advantage of MADV_FREE to return memory back to the system (jemalloc?).Same as previous one, but should be faster: allocate memory pools for small objects using mmap and release memory back to OS using madvise and MADV_DONTNEED/ MADV_FREE.Memory chunks of size greater than M_MMAP_THRESHOLD are immediately released back to OS. Try destroing that pool afterwards if program logic allows this. Avoid allocating large number of small objects using malloc or operator new, instead allocate them from a memory pool of a size greater than M_MMAP_THRESHOLD.This should force trimming and should give memory back to OS using MADV_DONTNEED. If you can, try calling malloc_trim once in a while or after freeing a lot of memory.Looks like some other details of malloc implementation do not let it free memory.Īt the moment I can recommend following solutions: By default it is 128kb, while test program allocates and frees 5 GB of memory. According to mallopt(3) man page, parameter M_TRIM_THRESHOLD is responsible for giving away memory. Thie errors also happens when too many people use Tubecast (because YouTube only authorize an amount of data and close it when it's up to the treshold) : Wait few hours and it will go back. ![]() Looks like glibc does not give away memory back at all. Tubecast use HTTPS protocol, it needs your phone has the real date and time, please check it. Test program below does not seem to give away any memory to the system after freeing memory ( strace does not show sbrk calls that return memory back to the kernel): int main() Then, finally it calls _exit(), and only then is the memory restored to the operating system, all at once.Ĭan anyone offer me additional tips on how to proceed debugging this? Why won't my program give that memory back?Įverything here is based on GNU libc implementation of malloc running on Linux. After it finishes those, I observe only a minimal downward change in the apparent memory usage. I can step through various calls to free as it works through the global destructor chain. Debug print messages indicate program flow is as expected.ĭigging further via the debugger, I find that most of this memory is still in use when _run_exit_handlers is invoked at the end of main. So, no answers until now, but even so i discovered that my other Android device, an older GT-I8552B (with root), with Youtube App v13.03.58 works normally with TubeCast and found the Addon (SSPD server) to cast videos, instantaneously. ![]() Sounds like a leak, but it passes valgrind with only a few bytes leaked, all in places I'd expect. If I let it go long enough, it will use enormous amounts of that memory and swamp the box. ![]() As the application runs, I can watch its memory usage increasing steadily via htop's VIRT and RES columns, or the ps command, etc. It uses various third-party libraries, notably Boost 1.61. ![]()
0 Comments
Leave a Reply. |