Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Out of Memory

by CountOrlok (Friar)
on Mar 27, 2013 at 18:45 UTC ( #1025789=note: print w/ replies, xml ) Need Help??


in reply to Out of Memory

The second piece of code will basically match all the nulls and put them into an anonymous array and then put the size of that array into $nulls. From a couple of tests I did using Devel::Size, an array with half a million nulls will take up about 320 MB. If you go any larger, this will quickly exhaust memory on a standard computer.


Comment on Re: Out of Memory
Re^2: Out of Memory
by CountOrlok (Friar) on Mar 27, 2013 at 19:28 UTC
    Correction: an array of 5 million nulls will take up about 320MB.
      5 million nulls, even if it was double byte should take up less than 10 mb of memory no? If array overhead was double that, we're still at 20 mb of memory per copy?

      What is it about the workings of this second statement that causes it to consume so much memory?

      I'd like to understand how that works if anyone happens to know.

        ($nulls) = $_ = /\0/g;

        Distilling it down a little more, this also causes the out of memory error.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025789]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2014-07-14 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (257 votes), past polls