C++ delete operator

John Love-Jensen eljay@adobe.com
Wed Jun 25 11:28:00 GMT 2008

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

(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.)


More information about the Gcc-help mailing list