pkirsch has asked for the wisdom of the Perl Monks concerning the following question:
At the first prompt (via ps auxwf output):{ my $foo = 'X' x 100000000; getc; } undef $foo; my $foo = ""; getc;
Now, what I wanted to show: - the memory allocated for $foo is not released. What I read on several mailing-lists is that the optimizer does not return the memory to the OS, in the hope that the same variable will be used again. But what I'm missing is some kind of a 'free' statement in Perl, which definitely returns memory (and I not know yet, undef seems not to help).user 12310 2.1 4.8 211000 197024 pts/2 At the second prompt: user 12310 1.2 4.8 211000 197028 pts/2
gives (again output from 'ps auxwf'):$foo = 'X' x 100000000; getc; undef $foo; getc; $foo2 = 'X' x 100000000; getc;
As you see some RAM is given back to the OS (~50%, (99364/197020)) . BUT: I would expect that the Perl virtual machine (memory management) reuses the allocated RAM from $foo for $foo2.user 15185 18.0 4.8 211000 197020 pts/5 user 15185 5.0 2.4 113340 99364 pts/5 user 15185 4.3 7.2 308660 294684 pts/5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Garbage Collection, again
by BrowserUk (Patriarch) on Dec 23, 2008 at 10:46 UTC | |
by pkirsch (Novice) on Dec 31, 2008 at 12:11 UTC | |
by BrowserUk (Patriarch) on Jan 02, 2009 at 15:01 UTC | |
|
Re: Perl Garbage Collection, again
by ikegami (Patriarch) on Dec 23, 2008 at 10:22 UTC | |
|
Re: Perl Garbage Collection, again
by Anonymous Monk on Dec 23, 2008 at 09:34 UTC | |
by ikegami (Patriarch) on Dec 23, 2008 at 10:28 UTC | |
|
Re: Perl Garbage Collection, again
by pkirsch (Novice) on Feb 24, 2009 at 11:00 UTC |