in reply to Re^4: weak-reference set internally
in thread weak-reference set internally
You either need the parent to still be around. Then you need a strong reference. Or it is OK if the parent goes away. Then you need a weak reference.
If you have a strongly referenced relation between parent and child, you will need to call a special method (like, ->free()) to release the references you hold explicitly. As Perls memory management is based on reference counting, there is no other, implicit way to find out that a set of memory objects is not referenced from anywhere on the outside.
If you want a bit more sanity in managing such object forests, you can keep a reference to a "master" object for each tree, whose main purpose is to call ->free() on the topmost parent object of that tree.
|
|---|