But... what if the DB file is
really big? (Sometimes people tie a hash to a DB file because of the amount of data, not just for persistence.) When I tried the following test:
perl -MDB_File -MData::Dumper -e 'tie %h, "DB_File", "junk.db";
for ($i=0; $i<1_000_000; $i++) { $h{"key_$i"}="value_$i" };
warn "the hash is loaded\n"; sleep 15; warn "starting dump\n";
print Dumper(\%h); warn "the hash has been dumped\n"; sleep 15' > /dev
+/null
Memory usage stayed at about 27 MB (macosx/perl 5.8.6) while the hash was being built and throughout the first sleep, then climbed over 450 MB during the Dump phase. Data::Dumper was making its own internal copies of the keys and values.
(The "junk.db" file itself was 47 MB, and a plain-text print out of keys and values as I suggested above would probably be about half that.)
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.