more useful options | |
PerlMonks |
Re^3: out of memory problemby betterworld (Curate) |
on Sep 13, 2008 at 14:16 UTC ( [id://711118]=note: print w/replies, xml ) | Need Help?? |
You're right. The reuse of the address could be coincidence, but as the LEN stay 12, we can conclude that the buffer was never freed. I've done a little bit of testing too:
Running this through strace gives this output:
This shows that perl does not allocate memory between "TWO" and "THREE" (the variable in sub foo gets reused), but it does allocate new memory before running bar, even though it could reuse $var's memory for $var2. Including system('ps', '-Orss', '-p', $$) and die "$! $?"; in various places leads to the same conclusion without strace. One question remains: When does perl free memory? I can't quite believe that every lexical variable that has ever been used results in large stale memory blocks. This would be against the spirit of this excerpt from perlsyn: You wouldn't want memory being free until you were done using it, or kept around once you were done. Automatic garbage collection takes care of this for you.
In Section
Seekers of Perl Wisdom
|
|