This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/40042] delete doesn't always delete
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 May 2009 12:14:07 -0000
- Subject: [Bug libstdc++/40042] delete doesn't always delete
- References: <bug-40042-17576@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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