Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!mordor!sri-spam!ames!pasteur!ucbvax!denali.UUCP!bill From: bill@denali.UUCP (Bill Meine [Sun Rocky Mtn TSE]) Newsgroups: comp.windows.news Subject: Re: Problems with window/resource loops.. Message-ID: <8804202342.AA04039@denali.sunpeaks.uucp> Date: 21 Apr 88 08:03:15 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 26 I've had this problem with my code too. I ended up putting "destroy" methods in every object that keeps a handle on another object in it's own class or instance slots. These methods set any object-handle values in their object (dictionary) to nulls. They also usually send destroy messages to any other objects that they link to (setting up entire graphs for scavenging). Another way I found to avoid the problem is to keep only the name of other objects instead of their handle. Then, when a method needs to reference that object, it looks it up first. The technique is more computationally intensive, but always works. I have also wondered if expressing interest in an event will create a back-reference in the event handler that would keep an object around, but I haven't devised a test for that case yet. Sorry to say, I don't know of any way to take a direct look at the heap to try to track down the offending objects that have cyclic references. Avoidance is the only policy I have found to work so far. What would be nice is a garbage collector that can detect disconnected, self-referencing graphs and collect the whole mass. Many Lisp systems have (mostly) solved this problem already. -Bill (sorry about not including the original question)