in reply to Garbage Collection on Hash delete
if %foo has had a lot of elements in it. This is because perl does some caching and, while all the elements inside %foo are freed, the data structures perl has allocated for %foo itself will not normally be freed, as perl assumes that if you stuffed a half-zillion things in it once that you'll do it again. undeffing the array/hash/scalar forces perl to dump all the cache for the variable, which can be a significant amount of memory if you've put a million elements into the hash at one point.undef %foo;
|
|---|