This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C++ delete operator
- From: Kevin Gilbert <kevin952 at tpg dot com dot au>
- To: GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 26 Jun 2008 08:02:02 +1000
- Subject: Re: C++ delete operator
- References: <C48795C1.3188C%eljay@adobe.com>
Thx for the reply.
That is what I was hoping for. Specifically, I am interested in RedHat
Enterprise Linux 4 and have looked at the code for "free" where, under some
conditions, it will release heap memory back to the system.
I was having trouble tracking down the source for "delete"/"delete[]" to
verify that it did, in fact, call "free" after doing it's thing with
destructors & etc.
Once again, thx for the info.
Kevin
On Wed, 25 Jun 2008, John Love-Jensen opined:
> 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