[1247] in java-interest
Re: Garbage Collection
daemon@ATHENA.MIT.EDU (Tim Lindholm)
Sun Aug 27 20:23:52 1995
Date: Sun, 27 Aug 1995 13:50:41 -0700
From: lindholm@scndprsn.Eng.Sun.COM (Tim Lindholm)
To: java-interest@java.Eng.Sun.COM, phil@bga.com
Your question suggests that you equate garbage collection with reference
counting, where this problem with cycles is a classical issue. But the
Java garbage collector and memory management system doesn't use reference
counting. If either object in the cycle is reachable starting from the roots
of the computation (e.g. the machine registers, the stacks, etc.) then it
will be marked as in-use and kept, and so will the things it refers to,
including the other object in the cycle. When recursive tracing takes
you back to the beginning of the cycle you'll see that the first object
is already marked and stop tracing down that path. If neither object is
reachable from the roots, then neither will be marked as in-use and both
will be collected, despite their mutual references.
-- Tim
----- Begin Included Message -----
Date: Sun, 27 Aug 1995 13:03:18 -0500 (CDT)
From: Philip R Brenan <phil@bga.com>
Subject: Garbage Collection
To: java-interest <java-interest@java>
Suppose I have several mutually refering objects. I.e. A refers to B
which in turn refers to A. How will Garbage Collection know when to free
these objects, as their use count will always be at least 1?
Phil
http://www.realtime.net/~phil
----- End Included Message -----
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com