Hello all
I have the following two pieces of code that I thought were equivalent. However, the first runs smoothly, while the second (using map) progressively chews up memory until it crashes. Can someone explain the difference and what I need to do to get the second to work?
I am also under the impression that the second method should be faster. Is that true?
First method:
foreach (@objects) { $module->target($_); my $results = $module->process(); undef $results; }
Second method:
map { $module->target($_); my $results = $module->process(); undef($re +sults) } @objects;
Thanks for your help.
In reply to Memory leak in map function? by ezekiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |