Paul, thanks for the link to your module.  I'll check it out.

Basically, these leaks exist because of the necessity to have circular
references in our domain objects.  We used the scala::util::weaken to
weaken one side of the reference, which is the parent side.  Either
way, it would cause issues.  One of our access patterns is we load the
child object during a request, somewhere down the call stack, the
parent is created and associated (due to lazy loading).  The reference
to this parent is weak, though once the parent goes out of scope, it's
discarded, since child holds a weak reference to this parent.  But if
somewhere in a different lexical scope within a request this parent is
needed again, it's reference from child is now undef'd.

The same issue would exist if you reversed the roles.  When we first
load the object, it's associations are proxies, which only create the
object when first invoked.  They then change their reference to point
to the newly created association.  The problem is that this weak
association gets undef'd and the only way to detect this garbage
collection process is inside the parent's DESTROY method.  But once we
know we're being destroyed, I currently am not sure whether I can
replace all the references that point to the object being destroyed
with the original proxy, though allowing the parent to be garbage
collected, but retrieved again if needed.

We have a very large perl OO application, which although very well
structured, has grown rather large, so detecting all possible usage
patterns and fixing them by manually managing the lifecycles isn't an
option we want to entertain just yet:-)

Thanks and I'll check out your module.

Ilya

On Fri, May 21, 2010 at 8:28 AM, Paul Miller <listm...@voltar-confed.org> wrote:
> On Thu, May 20, 2010 at 6:54 PM, Ilya Sterin <ster...@gmail.com> wrote:
>> Looking at devel::peek, I can see what seems to be list of referents
>> to the object, so that information is I believe maintained.  What I'd
>> love to find out whether it's possible, is for me to walk the list of
>> graph of referents and replace all references to the object being
>> destroy with a proxy and then allow the object to go out of scope.
>
> I'm not totally sure what you're up to here, but I think a module I
> wrote a ways back may help.  I wrote it specifically for walking
> blessed objects to check for leaks and things.  I meant it for use
> during testing, but there's no reason you couldn't use it to audit
> memory structures to kill leakers.  Arguably it'd be better to find
> and stop the leaks, but if that's not realistic, this may help.
>
> http://search.cpan.org/perldoc?Devel::FindBlessedRefs
>
> I'm also not totally clear, as you mentioned weakening refs, why
> hasn't weakening the refs worked for you?  Did you mean this:
> http://search.cpan.org/~gbarr/Scalar-List-Utils-1.23/lib/Scalar/Util.pm#weaken_REF?
>  That should work...
>
> --
> If riding in an airplane is flying, then riding in a boat is swimming.
> 114 jumps, 47.2 minutes of freefall, 90.4 freefall miles.
>

Reply via email to