Should I aggressively release memory while reading a file, line by line? An example:
while (<FILE>) {
my $line = $_;
<process line>
undef($line);
}
"Undefing" the $line variable is a good option for reducing memory consumption?
Should I aggressively release memory while reading a file, line by line? An example:
while (<FILE>) {
my $line = $_;
<process line>
undef($line);
}
"Undefing" the $line variable is a good option for reducing memory consumption?
That should make no difference as the variable will be released as soon as the next loop iteration starts, whether you explicitly undef it or not.
No. See perlfaq3 for more on what you should (and shouldn't) do with regards to memory usage in Perl.
No. Unless the lines in your file are of wildly different lengths, and some of those lengths are enormous (10 megabytes and up let's say), why even worry about it?
Is there evidence that loop is consuming too much memory?