XP is just a number | |
PerlMonks |
Memory leaks and circular referencesby jdrago_999 (Hermit) |
on Sep 06, 2008 at 20:05 UTC ( [id://709543]=perlquestion: print w/replies, xml ) | Need Help?? |
jdrago_999 has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
System Specs: Perl 5.10, Ubuntu 8.04, AMD 64x2, 4Gb RAM. I am trying to understand why references that have gone out of scope are still hanging around. Given the following code:
I get the following output:
If I change the code for package main to this: I burn through 200Mb of RAM in 42 seconds. Using Scalar::Util's weaken function takes care of the RAM issue, but the weakened references disappear too soon (i.e. before I get a chance to use them!). Example:
Where can I look for a straightforward description of Perl, circular references, weaken, etc? UPDATE: - Now it burns through 52Mb RAM in 26 seconds. Not sure if that's good or bad. I would expect Perl to recycle the RAM. Is that expectation wrong? Sure, 52Mb is better than the original number of 200Mb, but I would like to see no leakage at all. Is it possible to do this without leaking memory?
Back to
Seekers of Perl Wisdom
|
|