This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C++ delete operator
- From: John Love-Jensen <eljay at adobe dot com>
- To: Kevin Gilbert <kevin952 at tpg dot com dot au>, GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 25 Jun 2008 06:27:13 -0500
- Subject: Re: C++ delete operator
Hi Kevin,
> When memory is released via the C++ "delete" operator, is memory every
> released back to the OS (as it is when "free" is used in C)?
Under the covers, "delete" uses the C free() routine, for every C++ platform
I've used. (Also, "delete" and "delete[]" do other things, so you can't
just use free or realloc and have things work as desired.)
If your platform's heap management (Standard C's malloc / free) releases
heap back to the OS, then the answer is: yes the memory is released back to
the OS.
In my experience, the stock memory management heap routines with that come
with Standard C (malloc, free) do not release heap back to the OS. But that
may be indicative of the platforms I've used, not necessarily true for all
malloc/free.
(I'm sure there are some C++ compilers that do not use malloc/free as part
of new/delete... but I can not name any.)
HTH,
--Eljay