http://www.perlmonks.org?node_id=447348


in reply to Tracking down memory leaks

Are you doing something like:
my @outfile; while (<INFILE>) { # Process stuff here. push @outfile, $newline; } foreach my $line (@outfile) { print OUTFILE $line; }

Why not just do something like:

while (<INFILE>) { # Process stuff here. print OUTFILE $newline; }
That code template will grow to a fixed size and stay at that size, regardless of how many lines are in INFILE or OUTFILE.