|
From: Nicholas N. <nj...@cs...> - 2005-08-27 16:36:16
|
On Sat, 27 Aug 2005, Christian Parpart wrote: > might it be, that free()/delete/delete[] keeps the mmap()d regions for > reuse Yes. Allocators rarely give memory "back", they just hang onto it and reuse it. Look at Valgrind's allocator for an example, in coregrind/m_mallocfree.c. It allocates "superblocks" of 1MB or more using mmap(), in newSuperBlock(). It divides that up into pieces to satisfy calls to malloc(). When heap blocks are freed with free(), they are marked as reusable and put onto a "free list" (adjacent freed blocks are merged into larger blocks). This free list is what malloc() consults first when looking for a heap block. The superblocks are never deallocated as such. Nick |