------- Comment #5 from jakub at gcc dot gnu dot org 2009-05-06 12:14 ------- That just means you have no idea how a memory allocator works. Returning all just freed pages immediately to the system is of course possible, but terribly expensive performance wise, since often on the following malloc call you'll need the memory again and mmapping it is very expensive. glibc malloc has many options which allow you to fine tune things to the behavior of your application, see mallopt or corresponding env variables, plus recent glibcs (last year or two, don't remember) use madvise syscall in certain cases to allow the kernel to reuse the pages for other process if needed, but if not immediately needed for other process can be fairly cheaply used by the current process for malloc again.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40042