Re: C++ delete operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux