![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Shrunk array takes more memory than originalby BrowserUk (Patriarch) |
on Nov 10, 2015 at 13:04 UTC ( #1147354=note: print w/replies, xml ) | Need Help?? |
Using total_size() rather than size():
As you can see, the total size occupied by the array has shrunk by 30%. When you initialise the array, you cause perl to allocate 10,000 * 8 (64-bit) pointers as a continuous piece of memory for the array, plus 10,000 * 24 bytes for the scalars = 320,000 bytes (plus a little extra for the array mechanics. When you assign to $#array, the size of the base array does not get reallocated (hence the size() doesn't change), but half of the scalars are reclaimed. So now you have 10,000 * 8 plus 5,000 * 24 = 200,000 (plus the little extra). 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
|
|