[Israel.pm] Garbage Collection Question
Oron Peled
oron at actcom.co.il
Sun May 9 00:46:35 PDT 2004
On Sunday 09 May 2004 09:00, Gaal Yahas wrote:
> On Sun, May 09, 2004 at 06:12:52AM +0300, Yossi.Itzkovich at ecitele.com wrote:
> > As far as I know , this is OS dependent. On Unix (and it is not
> > Perl-depended) freed memory doesn't go back to system, untill the process
> > is done.
This is the most common behaviour in Unix/Linux, since most processes
allocate memory via malloc(3)/free(3) which are library functions and manage
their own heap (which is in the process address space). Memory is taken
from the system only when there is no more memory in the heap to satisfy
the request. The implementations of free(3) don't bother returning memory
to the kernel, since it is almost impossible in a heap (because memory
is fragmented).
OTOH, if the process would use system calls like brk(2) or mmap(2) than
it can release the memory to the sytem. Most software doesn't do it, both
because of the programming work (manging your own memory), and the
performance hit (a system call per allocation).
Note that preallocating memory in Unix/Linux is usually harmless, as most
systems "overcommit" their memory and will actually allocate the requested
memory pages only when they are used (i.e: when the process tries to access
them).
Just my small nit-picking...
--
Oron Peled Voice/Fax: +972-4-8228492
oron at actcom.co.il http://www.actcom.co.il/~oron
Linux: The OS people choose without $200,000,000 of persuasion.
-- Mike Coleman
More information about the Perl
mailing list