When is it time for a 1.0 feature freeze?
Sean Kelly
sean at f4.ca
Sun Sep 3 11:11:23 PDT 2006
Stewart Gordon wrote:
> Walter Bright wrote:
> <snip>
>> 1) Few programmers realize that C/C++'s malloc/free/new/delete *never*
>> (and I emphasize NEVER) return memory to the operating system. All
>> free/delete do is return memory to the memory pool managed by the
>> runtime library, not the operating system. In order to actually return
>> memory to the operating system, one has to write their own memory
>> management code, which is a significant (and necessarily non-portable)
>> effort. Hardly anyone does that.
> <snip>
>
> Never? I can't believe you've tried every implementation out there,
> including your own, and found the same.
>
> Or does the spec forbid free or delete to return memory to the OS? I
> can't for the life of me see why this would be.
Memory can only be allocated and freed in pages, and a memory page can
obviously only be returned to the OS if it is completely empty. Not to
mention the issue of holes in what is typically supposed to be a
contiguous address space. Some allocators will re-purpose empty pages
if a different allocation size is needed, but I don't know of any that
actually return memory to the OS. I think huge allocations may be an
exception, as allocators typically obtain the memory for these in a
slightly different manner. But even then I'm not sure the memory is
"returned to the OS" on release in a manner that would actually decrease
the process virtual memory footprint.
Sean
More information about the Digitalmars-d
mailing list