I have a script I'm running, and as part of (the MUCH larger) application, there's a function that takes up so much memory that perl tells me i'm out of it. I've had it working elsewhere (I've modified it slightly and added some things), but need help.
The file I'm processing is REALLY large (hence the line by line read in) -- and when I say large, I'm talking about 500-2400 KB in size.
I've done some debugging and the results are REALLY confusing to me. Everything works fine ... until I get to the last statement of the while loop. I added a print I'm at the end of the while loop-ish statement, and it prints. However, a print I'm out of a while loop-ish statement doesn't print. IT NEVER LEAVES THE LOOP, but stops looping, seemingly.
Here's the code:
sub process_rare_RE { my $file = shift; my $PART3 = 0; my ($sums,$avgs,$ydata,@xdata,@frmt,@values); open(IN,$file) or die "$file failed to open: $!"; ## Reset sums for (0..3) { $sums->[$_] = 0 } while (<IN>) { @values = split /\t/, $_; if ( ($values[4] == 0 && $values[0] >= 2.5) || ($file =~ /Ts21/ && $values[0] == 2.5) ) { $PART3 = 1 } if($PART3) { next if $values[1] < 50; if ($_[0] == 3 || $_[0] == 1) { for (0..2) { $sums->[$_] += $values[$_+1] } $sums->[3]++; } if ($_[0] == 2 || $_[0] == 1) { push @xdata, $values[0]; for (0..2) { push @{$ydata->[$_]}, $values[$_+1] } } } } ## never gets here, hung up above (^) close IN; for (0..$#xdata) { push @frmt, [ $xdata[$_], \@{$ydata} ] } for (0..2) { $avgs->[$_] = $sums->[$_]/$sums->[3] } if ($Debug > 2) { print "\t\tReturn value for process_rare_RE is: \n +", Dumper( ($avgs,\@frmt) ) } return ( $avgs, \@frmt ); }
In reply to Out of memory help by dimmesdale
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |