I know that the scope of $letter is only in the foreach block but I've always wondered if $letter is completely returned to the program heap when it goes out of scope. I know it doesn't return all the way back to the OS but what about the program memory area? I'm not all that clear on perl's memory management internals but it has always seemed to me that there is the potential for heap memory fragmentation with the foreach my ... construct. Could the repeated allocation of the large array @letters followed by a much smaller allocation of $letters followed by some undef'ing and then reallocation be leaving some small bits of unusable memory in the heap? I've never actually crashed a program with this construct but I have always wondered (????) Is there a module to track this sort of thing?foreach my $letter (@letters){ $count{$letter}++; }
In reply to Re: Where are those memory leaks?
by periapt
in thread Where are those memory leaks?
by ezekiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |