http://qs321.pair.com?node_id=316947


in reply to Re: Mod_perl, Memory Leaks and WeakRef
in thread Mod_perl, Memory Leaks and WeakRef

Well you're right about DESTROY; after rereading perlobj I see it doesn't actually cause any reference destruction, but just gives the programmer a last chance to do some custom cleanup. So that's out. As for Graph::Directed, it utilizes an adjacency matrix which is why it doesn't introduce the reference problems I'm encountering. I chose to write my own graph class utilizing an adjacency list though since the graph itself must be persisted in a database, and building a table with an 'origin' => 'destination' mapping seemed more natural than trying to store a matrix or translate between the two implementations when moving between disk and memory.

Your last suggestion may well work, although I'll have to make some changes to the way I treat my graph object references. Actually perlobj suggests basically the same thing: "the best solution is to create a non-recursive container class that holds a pointer to the self-referential data structure. Define a DESTROY method for the containing object's class that manually breaks the circularities in the self-referential structure."

thanks for the input davido.


"The dead do not recognize context" -- Kai, Lexx