in reply to Memory tip
You might be interested in:
$ perl -MDevel::Size=total_size -wle' my @a; print total_size(\@a); @a=(1,2,3,4); print total_size(\@a); @a=(); print total_size(\@a); ' 56 <- Empty 136 <- With 4 numbers 72 <- Empty
The internal buffer of arrays and strings isn't shrunk when the array or string is shrunk in anticipation that it will grow again.
Also interesting:
$ perl -MDevel::Size=total_size -wle' sub foo { my @a; print total_size(\@a); @a=(1,2,3,4); } foo(); foo(); ' 56 <- Fresh variable 72 <- Fresh variable
Variable aren't even deallocated when they go out of scope!
|
|---|