From: Sean O'Dell Date: 2002-02-24T18:22:14+09:00 Subject: Re: Object/Memory Management "Jim Weirich" wrote in message > >>>>> "Sean" == Sean O'Dell writes: > > Sean> I will have to look again at the finalizing features...I > Sean> didn't know there was a way to set a finalizer to run > Sean> *before* the object was destroyed. Maybe my book is > Sean> outdated already? > > No, it's correct. The finalizer is still run after the "object" is > gone. However, we have cleverly arranged that all the information we > need for finalization (a reference to our SillyResource) is captured > in the finalization closure. Actually, wouldn't your example cause the object to never get cleaned up because of the reference to it, and wouldn't the object be dead by then anyway? What I thought would work better would be to just store the information that SillyResource encapsulates and then use the finalize enclosure to take care of the resources. FinalizingObject does a good job of cleaning up the resource and it doesn't really matter if it ends up hanging around until garbage collection because we're already used to letting objects float around in memory unused for awhile. Sean