I used to import File::Map to handle a file as if it was a normal scalar variable and it used to work fine. Yet recently I encountered a memory allocation error.
perl -wE 'use File::Map q(map_file); map_file my $f, q(bigdatafile);'
Could not map: Cannot allocate memory at -e line 1.
The only difference I see is that the file is quite large: about 2Go, and I have about 1Go of RAM + 2Go Swap.
Yet I don't understand why this should be an issue. map_file is not supposed to load the whole file in memory, is it?
I also noticed that there is a more standard perl module called Sys::Mmap that does the same thing. But it also gave me a memory allocation error.
What is the proper way to tie a large file to a scalar variable?
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.