Glad you got an speedy explanation. It seems so obvious once it is pointed out, but then no one else here spotted the cause either:(
It very non-intuative that the rates of memory growth you were seeing could be attributed to the simple act of stringifying previously numeric values. Once you know what to look for, it is easy to see the how quickly the memory usage grows when ths happens.
A (minimum) of 70% growth for integers:
c:\Perl\test>p1 [0] Perl> use Devel::Size qw[ total_size ];; [0] Perl> @a = (0) x 1e6;; [0] Perl> print total_size( \@a );; 20000056 [0] Perl> $_.='' for @a;; [0] Perl> print total_size( \@a );; 34000056
And a whopping 300% for floats.
c:\Perl\test>p1 [0] Perl> use Devel::Size qw[ total_size ];; [0] Perl> @a = ( 1.0 ) x 1e6;; [0] Perl> print total_size( \@a );; 24000056 [0] Perl> $_.='' for @a;; [0] Perl> print total_size( \@a );; 75000056
Definitely one to remember if you are running close to the memory limits of your machine.
In reply to Re^2: Memory Error Printing Multiple Hashes Simultaneously
by BrowserUk
in thread Memory Error Printing Multiple Hashes Simultaneously
by bernanke01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |