How to return GC-d memory back to OS
Serg Kovrov
kovrov at no.spam
Thu Aug 3 09:56:49 PDT 2006
* Oskar Linde:
> For a long time, even linux malloc()/free() would not return memory to
> the OS. Usually, memory is allocated from the OS using brk() or similar
> system calls and an application can only return memory from the end of
> the virtual address range the application has been allocated. In
> general, this requires a relocating/compacting GC, as even a single
> allocated byte at the top end of your virtual address space will prevent
> the OS from shrinking it.
>
> But apart from needing much swap space, there are no draw backs of using
> much virtual memory. The memory you don't use (but exists in your
> virtual address range) will not map to physical memory and will not
> affect your computers performance.
>
> /Oskar
I'm not sure, Oskar, as I am not an expert in that matter...
But... I'm not tried on linux but on Windows (my target OS is 2000/XP
family so far) 'delete' do exactly what I want.
For example, in C++ (GCC/mingw) I could allocate with 'new' 50Mb, and
see in task manager or performance monitor that my "private bytes" are
increased about that size. When I 'delete' it, I see that "private
bytes" count is dropped to the same level it was before. Nice.
As I understand "private bytes" are amount of memory my process uses
exclusively and can not be used by anyone else. And that I define for
myself as memory footprint - correct me if I wrong.
Same example in D show that GC greedily hold everything it get from OS.
And that is definitely what I do not want.
More information about the Digitalmars-d-learn
mailing list