in reply to Reducing memory footprint of strings
However, Perl seems to very stubbornly insist on using 32 bits for each character.
That's not true.
ASCII characters require one byte.
Other iso-8859-1 characters require one or two bytes.
Other Unicode characters require up to four bytes. (Usually two. Practically, never four.)
Both Devel::Size and a peek at the size of the internal of the internal show differently.
$ perl -MDevel::Size=total_size -E'say total_size("A" x 1024 x 1024 x +100)' 104857636 $ perl -MDevel::Peek -E'Dump("A" x 1024 x 1024 x 100)' 2>&1 | grep LEN LEN = 104857604
The rest of the memory was used to build the string and is available for reuse. There's also the possibility that you are making a copy of the string by using it as the return value of the file. (Do you see a difference from appending ";1"? I'm getting 0 from time.)
|
|---|