Quick question: does keeping a reference to an array element or hash value prevent the freeing of the container object when all the "direct" references to it go away? My impression (90% sure) is that the answer is no - elements do not impose "upward reference-counting" to their container (it would be blatantly anti-DWIMish and a severe source of memory leaks) - but I want to be 100% sure.
# create a reference to an anon array my $aref = [1..100]; # take a reference to one of its elements my $elem_ref = \$aref->[50]; # drop the array reference undef $aref; # is the anon array still gobbling up memory in a zombie state?
In reply to Query on refcounting with container objects by calin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |