http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53169
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-30 15:13:07 UTC --- Similarly, calling malloc_trim(0) after test() causes glibc to immediately return the memory to the system (requiring a sbrk system call next time memory is needed) You should probably use sbrk and/or experiment with http://www.gnu.org/software/libc/manual/html_node/Statistics-of-Malloc.html to see what's actually happening in your program, and maybe using mallopt() to adjust things.