From: Josef Wolf Date: 2006-09-07T01:50:13+09:00 Subject: Re: How to store/load persistent data? On Wed, Sep 06, 2006 at 07:10:18AM +0900, Logan Capaldo wrote: > On Sep 5, 2006, at 5:40 PM, Josef Wolf wrote: > > class Foo > > def initialize > > canvas = TkCanvas.new.pack > > rect = TkcRectangle.new(canvas, 0, 0, 50, 50, "fill"=>"white") > > end > > end > > > > begin > > x=Foo.new() > > end > > > > GC.start > > > > # Object destroyed but canvas and rectangle are still alive > > > > Tk.mainloop > > > >I can't see a solution for this problem since I am a novice for > >ruby/OO/Tk. > >How do you gurus handle such situations? > > That just means that there is still a reference to those objects. > When all the references go away, then and only then ruby will collect > them (if it needs to.) Exactly. The Tk library holds the references. To get rid of them, I need to call canvas.delete(rect) for the rectangle and canvas.destroy for the canvas. When I add those two calls, they disappear without messing with the GC.