This is the mail archive of the
mailing list for the GCC project.
re: memory allocation
- From: Dan Kegel <dank at kegel dot com>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>, gcc-help at gcc dot gnu dot org, laczo dot tibor at pro dot hu
- Date: Sat, 13 Sep 2003 08:26:14 -0700
- Subject: re: memory allocation
- Reply-to: gcc-help at gcc dot gnu dot org
Laczó Tibor wrote:
[ In Redhat Linux, how come calling delete on objects in C++
doesn't return memory to the operating system? Even after
my program deletes all its big objects, RSS doesn't shrink. ]
That's an FAQ. http://www.lysator.liu.se/c/c-faq/c-3.html says
Q. I have a program which mallocs but then frees a lot of memory,
but memory usage (as reported by ps) doesn't seem to go back down.
A. Most implementations of malloc/free do not return freed memory to
the operating system (if there is one), but merely make it available
for future malloc calls within the same process.
glibc's manual also mentions this:
"Occasionally, free can actually return memory to the operating system
and make the process smaller. Usually, all it can do is allow a
later call to malloc to reuse the space. In the meantime,
the space remains in your program as part of a free-list used internally by malloc."
Please take this discussion to firstname.lastname@example.org
or maybe comp.lang.c++.
email@example.com is for gcc maintainers, not users.