Problems? Is your data what you think it is? PerlMonks

### Comment on

 Need 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

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.

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!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• 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: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
 [hippo]: Marketing should not be allowed near such utilities.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (15)
As of 2017-05-24 14:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My favorite model of computation is ...

Results (184 votes). Check out past polls.