Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Object not garbage collected because of Busy Monitor

807580Sep 3 2009 — edited Sep 4 2009
Hi all,

I've been trying to work out why this object is hanging around hogging memory when I had thought I had set all references to it to null.

I did a heap dump and looked at it with the Eclipse Memory Analyzer. After getting rid of the few references I had missed, I'm still stuck with one -- going back to the Busy Monitor. (Which I don't quite understand, for forgive me if I misuse terms...)
Shortest path to GC roots:

 javax.swing.TimerQueue   Busy Monitor
   - firstTimer  javax.swing.Timer
    - listenerList  javax.swing.event.EventListenerList
      - listenerList  java.lang.Object[2]
        - [1]  org.mycompany.MyObject$1
          - this$0  org.mycompany.MyObject
So I gather that the Busy Monitor has to do with any threads that use wait(), notify() or are in synchronized blocks. Well, I do have a thread that I call notify() on in a synchronized block in that class, but when I want to destroy my object, in my destroy() method I call "myThread = null." (And myThread is private, so nothing else should have it). Shouldn't this work to kill it? Why is it sticking around?

Any help greatly appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 2 2009
Added on Sep 3 2009
3 comments
616 views