OK, The bigger picture. Here goes ...
It basically has to do with circular references.
To deal with them we could use Scalar::Util::weaken or just cleanup the objects manually.
Scalar::Util::weaken won't work for me because the code often refers to a "parent" object via a "child" and vice-versa. I'll illustrate:
sub circ_ref { my $dad = {}; my $son = {}; $dad->{son} = $son; $son->{dad} = $dad; Scalar::Util::weaken $son->{dad}; return $dad; } my $dad = circ_ref(); # All is well my $son = circ_ref()->{son}; # Doh! Who's your daddy? print Data::Dumper::Dumper $dad, $son;
So instead I have to cleanup the objects manually, but at what point? The references to either "parent" or "child" may hang around for while. Only when they have both gone can I cleanup the circ-ref. To do this I need to know when the REFCNTs have dropped to 1.
So I was trying to find a way to "hook" SvREFCNT_dec for these objects, but I guess this is just not possible.
Is there another way to do the cleanup?
In reply to Re: Intercept any changes to the sv_refcnt/SvREFCNT of an object
by vernonlyon
in thread Intercept any changes to the sv_refcnt/SvREFCNT of an object
by vernonlyon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |