On Sat, Dec 30, 2000 at 12:58:49AM -0500, Scott Gregory Miller wrote:
> > 
> > I just know some of the basic rules on how to use memory efficiently
> > in a GC environment.  One possible memory leak is the
> > protected/private memory leak, which is a major problem in Java that
> > is somewhat equivalent to the classical memory leak in languages such
> > as C and C++.  What this memory leak is where a reference to an object
> There is no such animal in Java.
> 
> > is passed to another object through a function call.  The other object
> > stores the reference in a protected or private variable, list, array,
> > etc. so that when the main program loses the reference to the object a
> > non-circular reference to the object still exists.  The main way to
> > solve this problem is to properly use remove/unregister/delete
> > functions to do stuff like properly remove references to things such
> > as listeners from objects.
> This is unnecessary in Java.  You can certainly help the GC this way, but
> unlike bolt-on GC in other languages, its not really necessary.
> 
> > 
> > The problem with GC is that it has a tendency to make programmers
> > forget that memory management is important.  Even with GC, you still
> > have to worry about memory leaks and memory usage.  With languages
> > such as C and C++, you *must* pay attention to these things, while GC
> > often allows programmers to forget about these things because GC
> > handles a lot of this stuff behind the scenes.
> No you don't.  You're thinking about GC in languages that weren't designed
> for it.

No, this animal really does exist in Java.  Actually, it is a major
issue in Java.  If it wasn't a major issue in Java, then at least one
major article in an issue of Doctor Dobb's Journal was a complete
lie.  A prominent example of this is you pass an object to another
object as a listener.  If you forget to remove the former object from
the latter object, the former object will never be GCed as long as the
latter object exists.

-- 
Travis Bemann
Sendmail is still screwed up on my box.
My email address is really [EMAIL PROTECTED]

PGP signature

Reply via email to