Thanks for your response Thomas. Due to my lack of experience with PERL code, I'm not very sure what that code snippit you sent means. I'm going to attach a couple of lines of the code that I've been working with.... if it's not too much trouble, maybe you could suggest how it could be improved upon so that when the window is closed, PERL will be able to destroy the entire object. (Perhaps I should add some lines to my Ondestroy method..... what might they be??)
${$canvasobj->{'canvas'}}->bind($movebox, "<Button-1>", sub { &StartMove($canvasobj, $box, $moveclickref, $newboxx1ref, $newboxy1ref, $newboxx2ref, $newboxy2ref); }); In the code above, I have an object called $movebox that is drawn onto the canvas object $canvasobj. This snippit is where I bind the initial mouse click to start the subroutine that controls the moving of the $movebox object. Is there any way to rewrite the bindings within my $movebox package so that when I close the toplevel window to the canvas I am able to break the circular reference and thus destroy both the $canvasobj and the $movebox object?? Thanks again Thomas Andrew Thomas Drugeon wrote: > Hi, > > If you bind an object in Tk it will remain referenced and will never be > DESTROYed... > Here is the work around I use: > > $widget->bind("<1>" => [sub($self->method()); # will stay referenced... > => > $widget->bind("<1>" => [sub($_[1]->method()}, $self]); > > thomas > > ----- Original Message ----- > From: "Andrew Mueller" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, June 18, 2003 12:21 AM > Subject: Memory leaks > > > > > > > > > > Hello, > > > > > > I've been experimenting for a couple of hours now with fixing the > > > memory leaks in my program. I have been using the subroutine > > > > > > sub DESTROY { > > > > > > print ("$classname destroyed\n") > > > > > > } > > > > > > to determine when my objects were going out of scope and being cleaned > > > up by PERL. I'm certain that you are familiar with the DESTROY > > > method. I haven't been able to find any circular references but when > > > I destroy some object types, it seems that PERL still isn't cleaning > > > them up. On all occassions, the only objects that I can't seem to > > > destroy properly, are the ones that are window based and that have > > > some sort of 'bind' or 'canvasbind' feature that I've built into > > > them. These types only seem to clean themselves up when I exit the > > > entire program. > > > > > > Is there a way to use 'bind' or 'canvasbind' such that it does not > > > produce a circular reference between the canvas object and another > > > object that is binded to the canvas? Is there an unbind command that > > > would release the hidden references?? > > > > > > Sincere thanks, > > > > AM > > > > _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs