Welcome to the Monastery | |
PerlMonks |
Re: Devel::Size reports different size after hash accessby BrowserUk (Patriarch) |
on Oct 25, 2016 at 20:25 UTC ( [id://1174732]=note: print w/replies, xml ) | Need Help?? |
The problem is that you are using the numeric values of the hash in a string context: print $fh "$key $hash{$key}\n";; thus perl converts what were IVs (internal integers) into PVs (internal strings), caching the result in the expectation you might use them in a string context again. As an IV, each value requires 24 bytes, but once converted to a string and stored in a PV, each value requires ~56 bytes. You can avoid the conversion being cached by making perl convert a temporary value to a string for printing like this:
That will avoid the memory growth. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|