[comp.windows.news] Problems with window/resource loops..

siegel@hc.DSPO.GOV (Josh Siegel) (04/19/88)

We have a very large NeWS application that very recently started
having problems with not going away when we zapped it.  We went
back to old code and can't figure out what has gone wrong.

We assume/guess the problem lies with a self referencing window  (or
windows. ie. Window loop).

Are there any methods/tools written for finding such loops
or for helping the system get rid of the windows even with
such loops?

	thanks much

		--Josh Siegel

P.S> On to invent the wheel....
-- 
Josh Siegel		(siegel@hc.dspo.gov)
I like using a C-47A "puff dragon" to go hunting with.

bill@denali.UUCP (Bill Meine [Sun Rocky Mtn TSE]) (04/21/88)

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)

singer@Apple.COM (Dave Singer) (04/22/88)

In article <8804202342.AA04039@denali.sunpeaks.uucp> bill@denali.UUCP (Bill Meine [Sun Rocky Mtn TSE]) writes:
>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.

In the absence of a full GC (that at least should click in when NeWS would
otherwise say 'Out of memory'), I wrote a small piece of lispscript/postscript
that finds circular references from a given object (dict, array, or other
structured type such as event), chasing at most 'n' pointers.  It does the
obvious 'tree' search, so it takes ages to chase to more than a few levels.
It's helpful to do it this way, coz often one can test each class/individual
in isolation.  I don't have the code anymore;  maybe someone at SUN SPE or
at Schlumberger could post circular.ps/.pls if it was warranted.

Dave Singer