[Israel.pm] Garbage Collection Question

semuel semuel at semuel.co.il
Mon May 10 10:13:56 PDT 2004


Hello There.


Why does everybody sees only the bad things?
Think positively: the unwanted allocated memory won't be accessed, and the
OS will eventually flash the inactive memory pages to the swap, where they
will sleep until the application will need that memory again.
No big deal.

Semuel.


-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf
Of Jason Elbaum
Sent: Sunday, May 09, 2004 11:45 AM
To: Perl in Israel
Subject: Re: [Israel.pm] Garbage Collection Question

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
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://www.perl.org.il/mailman/listinfo/perl






More information about the Perl mailing list