So I had this question as well.
However I am also interested on how you can make a hash of arrays memory efficient.
- I am adding arrays to a hash.
- I am adding several arrays to one hash key
- I am doing this to then compare the contents of arrays within one key for differences.
- My processing will use over 84566 Hash Keys
- My Processing will capture over 94269 arrays (Each with 30 values)
push @{ $eventHash {$EventScheduleReference} }, [@tmpxmlarray];
However this uses all my available memory and the program terminates.
I have tried using the following to avoid RAM usage
tie (%eventHash, 'DB_File', 'eventHash.db', O_CREAT|O_RDWR, 0644) ||
die ("Cannot open eventHash.db");
However memory use seems to be the same and the program terminates. Also..interestingly when using strict refs...under a tie'd condition, an attempt to push to a duplicate key causes the following error:
Can't use string ("ARRAY(0x11614e8)") as an ARRAY ref while "strict re
+fs" in use
Any ideas on how to force the Hash onto Disk and/or use less RAM to store the hash of arrays?
I assume I am only storing ARRAY references in the Hash and that the data in the arrays are still being stored semi-anomalously in RAM somewhere....although I can see the array data in the tie'd file...this might just be due to the way a tie uses random memory junk during file creation.
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.
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, details, 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, summary, 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?
See Writeup Formatting Tips and other pages linked from there for more info.