You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Radovan Semancik <se...@bgs.sk> on 2000/12/20 11:14:55 UTC

Freeing cyclic refferences

Hello!

I have perl objects with cyclic refferences to each othen in mod_perl
environment. I know that these objects will never be freed unless I
break the refference cycle. But, how to do it transparently for user of
object?

Is there a way in perl for making a refference to object that is not
counted in refferrence count? I tought of symbolic refferences, but I
suppose they are far more ineffective that 'normal' refferences. Am I
right?

-- 
                            Ing. Radovan Semancik (semancik@bgs.sk)
                         System Engineer, Business Global Systems a.s.
                                   http://storm.alert.sk

Re: Freeing cyclic refferences

Posted by Marc Spitzer <ms...@optonline.net>.
in 5.6 there is a weaken? pragma, this should do what you need.

marc

----- Original Message ----- 
From: Radovan Semancik <se...@bgs.sk>
To: <mo...@apache.org>
Sent: Wednesday, 20. December 2000 5:14
Subject: Freeing cyclic refferences


> Hello!
> 
> I have perl objects with cyclic refferences to each othen in mod_perl
> environment. I know that these objects will never be freed unless I
> break the refference cycle. But, how to do it transparently for user of
> object?
> 
> Is there a way in perl for making a refference to object that is not
> counted in refferrence count? I tought of symbolic refferences, but I
> suppose they are far more ineffective that 'normal' refferences. Am I
> right?
> 
> -- 
>                             Ing. Radovan Semancik (semancik@bgs.sk)
>                          System Engineer, Business Global Systems a.s.
>                                    http://storm.alert.sk
> 


Re: Freeing cyclic refferences

Posted by Darren Duncan <da...@DarrenDuncan.net>.
On Wed, 20 Dec 2000, Radovan Semancik wrote:
> I have perl objects with cyclic refferences to each othen in mod_perl
> environment. I know that these objects will never be freed unless I
> break the refference cycle. But, how to do it transparently for user of
> object?

What you need to do is to have a "starting" node in your
reference cycle that doesn't have anything pointing to it.  Such as the
"head" pointer of a linked list.  If the DESTROY method of this object
were to explicitely call some clean-up method of yours that is in the
regular node objects (clearing internode references), then the whole
process should be transparent to the user because all they have to do is
remove any references to the starting node, and they all vanish.  If your
entire set of linked objects is encapsulated in another one, then that
would effectively be your "start".

// Darren Duncan