[Israel.pm] Garbage Collection Question

Jason Elbaum Jason.Elbaum at freescale.com
Sun May 9 02:44:38 PDT 2004

Yuval Yaari wrote:

> When that variable goes out of scope or is catched by the
> garbage fairy, Perl will not release that 1MB to the kernel right away, it
> will reuse it in case it needs it later on during execution."

Many operating systems never really allow a process to return allocated 
memory to the OS until the process exits. Processes can only grow, not 
shrink. This may be due to an assumption that if a process once needed X 
MB, it will probably need it again some time, and the churn by 
repeatedly allocating and deallocating it to the process is more 
expensive to the OS than just leaving it there.

As a rule of thumb, you're better off not allocating massive data 
structures unless you really need to access all the data at once.

Jason Elbaum

More information about the Perl mailing list