Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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.

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025789]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2018-04-26 04:39 GMT
Find Nodes?
    Voting Booth?