>>>>> "AA" == Alex Aminoff <[EMAIL PROTECTED]> writes:
AA> Using Devel::Peek or Internals (from CPAN), you can find out the AA> refcount of a thing. I would like to go a step further and list AA> what objects/data bits refer to the thing. I realize this probably AA> requires exhaustively searching all the symbol tables or something AA> like that, but it should be theoretically possible, if AA> computationally expensive. AA> The reason I want to do this is that we have some objects that are AA> not being DESTROYed when we expect, and thus not closing their AA> database handles. We have tried figuring out where the circular AA> reference is by inspecting our code to no avail. (We reason that AA> if we can find out what points to our object soon after creation, AA> references that would later be circular are not yet so and we AA> should be able to find them). have you thought about weak references? if you maintain a key reference (or a few) as regular and make the rest weak, it will be much easier for to detect when something has gone out of scope. another trick is to use a second level reference above the circular structure which only has one copy. when it gets destroyed it can explicitly break the circles below it and also close down stuff. there is a name for this paradigm but i forget it. another way which i use is to explicitly close down stuff and not rely on destroy. then you get exact control over shutdown time and change the worries of perl to you! :) AA> Is there a module that does this? Or perhaps a function of the debugger? it would not be hard to write a symbol tree walker and i bet something exists on cpan that you could use. then it would be easy to compare the values to your known ref. but this begs the question, how are you making your data structures that you can't track multiple copies of some ref? making a circular structure doesn't happen randomly. one area that is common and not understood is with callbacks. usually the main object has a ref to the thing which does the callback and the callback thing needs a ref to the object to call it back. a circle but not obvious. weak refs work well there. a good code analysis will also help. you shouldn't be creating such problems without understanding how they got created. scanning the symbol table is a backwards solution IMO. you will still have to fix the code in some way to eliminate the circles and/or force timely destruction. i can assist with any of these solutions if you want more help. uri -- Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org _______________________________________________ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm