Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Your analogy doesn't help.

You are constructing a 3-dimensional array, and you are running out of memory. Assuming $data[ 0..X ][ 0..Y ][ 0..Z ];

What we need from you is:

  1. the maximum size of those three dimensions X, Y, Z?
  2. Are the dimensions contiguous or sparse?

    If sparse, the approximate density?

    If one or more of X,Y & Z can run say 3000 .. 4000; or if instead of using every number between 0 ..m; you only use every 10th or 100th; then you can save substantial space by using a hash instead of an array for that dimension of the structure.

  3. Do you need to build the entire dataset before you can calculate your statistics>

    Could you build (say) all of $data[1][Y][Z] for X=1; calculate the stats; and then discard that before building all $data[2][Y][Z] for X=2?

  4. What are you storing in each element of that 3d array?

    Is it just a number? If so, how big will that number get?

    If, for example, each element of the array held an integer < 255, the you can easily substitute a string for the 3 level arrays and save huge amounts of memory.

    Eg. This constructs a 100x100x100 3d array of small integers which requires 33MB of memory.

    @data = map[ map[ map int( rand 256), 0..99 ],0..99 ], 0..99;; print total_size \@data;; 33454784

    This on the other hand construct 100x100x100 2D array of strings. It contains the exact same information, but it only requires 1.6MB:

    @data = map[ map pack( 'C*', map int( rand 256), 0..99 ), 0..99 ], 0.. +99;; print total_size \@data;; 1614784

If you give us the information we ask for, we can almost certainly help you reduce your memory requirements.


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".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Memory issue with cancer data (analogy) by BrowserUk
in thread Memory issue with cancer data (analogy) by ZWcarp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (4)
    As of 2015-07-03 03:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (48 votes), past polls