RobinV has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Out of Memory..
by Corion (Patriarch) on Dec 15, 2009 at 08:43 UTC | |
by ikegami (Patriarch) on Dec 15, 2009 at 15:26 UTC | |
by RobinV (Sexton) on Dec 15, 2009 at 09:17 UTC | |
by Corion (Patriarch) on Dec 15, 2009 at 09:23 UTC | |
by RobinV (Sexton) on Dec 15, 2009 at 09:29 UTC |