Hello PerlMonks,

I am having some issues with Memory in a very simple application. That I run in Strawberry perl on Windows. The code goes like this:

my $f1 = $ARGV[1]; my $f2 = $ARGV[2]; my $b1 = undef; my $b2 = undef; open f1_p, "<$f1" || die "Fatal'd\n"; open f2_p, "<$f2" || die "Fatal'd\n"; while (<f1_p>){$b1.=$_;} while (<f2_p>){$b2.=$_;} close f1_p; close f2_p; undef(@ARGV); #Free Memory? my($old, $new) = String::Diff::diff($b1, $b2);

Anywho, when the app runs it runs out of memory. This is a 4GB RAM Rig. With a 3GB SWAP File. So that's about 6GB of Memory the Application can use and run on.

The 2 files I tried are both 600MB, so in my calculation it uses. 1200MB and the extra resources that String::Dif::diff uses so thats about. 2400MB so I think I can say 3GB of RAM if I go way out of range.. But as far as I know (and correct me if I am wrong) is 3GB still smaller then 6GB so it should fit easily..

Is there an 'easy' way to fix this application?
eg setting this code to bytecode? Or anything like that? Or can I make some memory 'hacks'??


Anyway, thanks already I hope somebody can tell me where to look what to read or offer me a way to fix this.
--

Cheers,
Robin


In reply to Out of Memory.. by RobinV

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.
  • 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:
    & &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.