in reply to Re: Memory Managment with Subroutines and Objects
in thread Memory Managment with Subroutines and Objects
There is one thing that you do need to review, and that is, “weak references.” See also: Scalar::Util.
If you construct a “self-referential” data structure, in which everything contains references to everything else, thus forming an “endless chain” of references, you will need to weaken one or more of those references in order to “break the chain.” In other words, you are “deliberately creating a weak point in the structure,” so that the garbage collector will eventually be able to deduce that the data structure is eligible for reaping when no other references to the data remain other than the data’s own self-references to itself. Without this (and only in this very specialized situation), a memory-leak can result.