Re: Java and Large Applications



On Thu, 2 Jun 2005 00:43:20 +0800, G. Ralph Kuntz, MD wrote
(in article <1117644200.398663.294920@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>):

> I'll probably get flamed, but...
>
> I just spent the morning fixing my umpteenth "memory leak" in a large
> Java application (~200,000 lines) that I have been writing for several
> years. Again, it turns out to be "hidden" pointers inside Swing that
> hold on to DefaultMutableTreeNodes even though I explicitly set the
> tree root to null (the hidden pointer has to do with TreePath). This
> prevents the 200,000 tree nodes from being garbage collected until the
> tree itself is freed.
>
> When I first started learning C++ about 20 years ago, I had an implicit
> distrust in a language with so many "side-effects" in the underlying
> library that I could never know about.
>
> I considered (toyed with) the idea of rewriting my Java app in C. Of
> course, it would probably be 1,000,000 lines long, but at least I could
> control every memory allocation and deallocation.
>
> So much for garbage collection.
>
> Any thoughts?
>

check out the sun site, it clearly states that setting pointers to null to
cause GC is a BAD IDEA.
making your references weak is far better.


.



Relevant Pages

  • Java and Large Applications
    ... I just spent the morning fixing my umpteenth "memory leak" in a large ... tree root to null. ... I considered the idea of rewriting my Java app in C. ... So much for garbage collection. ...
    (comp.lang.java.programmer)
  • Re: Implementing trees without pointers?
    ... I have problems with implementing tree without pointers. ... It is a common misconception that Java does not have pointers. ... references, which are very much alike C++ pointers. ...
    (comp.lang.java.help)
  • Re: The Java no pointer big fat lie!
    ... > reference types, it wouldn't be a good comparison. ... and what you can't - and there is a big difference in Java to C and C++. ... You cannot change it in the language itself, ... Thus I would distinguish pointers from ...
    (comp.lang.java.programmer)
  • Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
    ... What matters is that Lisp teaches students to use ... recursion, because they have to. ... Java does NOT teach students to use ... pointers and recursion, she'll be able to understand anything, and get ...
    (comp.programming)
  • Re: Java
    ... >> seem to me to be one of the major uses of pointers. ... >As soon as I see a production OS built on java and not assembler at the ... seem like a good choice for writing an operating system. ... needs to be taught, and can't be taught using Java. ...
    (comp.programming)