good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^2: Strings and numbers: losing memory and mind. (SV sizes)by almut (Canon) |
on Sep 28, 2007 at 13:28 UTC ( [id://641526]=note: print w/replies, xml ) | Need Help?? |
Using an integer as a string usually makes for a considerably larger (in memory) scalar than using a string as a number. How does this fit in with the size that Devel::Size reports? If you can trust it, a stringified number, and a numified string result in the same size (32 byte for the value 123, on a 32-bit Perl).
outputs something like
Devel::Peek shows a comparable resulting structure for "number stringified" and "string numified" (with respect to IV and PV usage). Also, one can observe that the overall size gets larger if you make the number bigger, and then re-stringify the variable... Anyhow, does your comment mean that Devel::Size is not reporting the size related to the entire PV buffer allocated for the cached stringified form, but rather its currently used part only (up to and including the \0)? — which would make it a less useful tool for determining real memory usage. Actually, the size that Devel::Size reports seems to be related to the LEN in the Devel::Peek dump (which itself you can observe to increment in steps of 4, if you play around a bit). Just wondering...
In Section
Meditations
|
|