aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Disposing JDialog increases CPU usage up to 100% Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Disposing JDialog increases CPU usage up to 100%" Watch "Disposing JDialog increases CPU usage up to 100%" New topic
Author

Disposing JDialog increases CPU usage up to 100%

Andreas Pax Lück
Greenhorn

Joined: Nov 04, 2009
Posts: 18
Hi Java friends.

I'm confronted with a really strange issue. I cannot reproduce the problem in another case, but only in this single case. Perhaps, you did already gather some experiences with this:

I'm showing a modal JDialog in a main frame context. The default close operation was set on DISPOSE_ON_CLOSE. As soon as I close the JDialog its dispose method is invoked continuously all the time. It never ends and the CPU usage increase on 100%.

I checked similiar JDialogs of my application but the strange behaviour doesn't occur. The main frame which creates the JDialog instance doesn't store any reference to it and the JDialog doesn't execute any further threads.

I have no idea what's going wrong. Is it a JVM bug? Or is there's something wrong with my implementation?

Best regards



Uncle PAX





This is a piece of the source code. The file transmission thread isn't active when the JDialog becomes disposed. But the AWT event dispatching thread calls the dispose method immediatly without blocking the AWT queue.


"Wenn man irgendwann mal von allen akzeptiert wird, dann weiß man, dass man irgendwas falsch gemacht hat."
Excerpt by: Mr. Weidner
Andreas Pax Lück
Greenhorn

Joined: Nov 04, 2009
Posts: 18
The JDialog's further highlights:

  • uses CardLayout
  • shows an animated GIF file with animation loop
  • contains a JTable with an own cell renderer (nothing special)
  • Darryl Burke
    Bartender

    Joined: May 03, 2008
    Posts: 4658
        
        5

    Andreas Pax Lück wrote:
  • shows an animated GIF file with animation loop

  • Clarify 'animation loop'

    Your problem may be in the nature of this fixed bug
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4302818


    luck, db
    There are no new questions, but there may be new answers.
    Andreas Pax Lück
    Greenhorn

    Joined: Nov 04, 2009
    Posts: 18
    It's an endless GIF animation. But even if I remove this GIF image from the dialog this bug occurs.

    I was running Java 1.6_18 and now I tried 1.6_21. No success.
    Ernest Friedman-Hill
    author and iconoclast
    Marshal

    Joined: Jul 08, 2003
    Posts: 24187
        
      34

    Put something like this in dispose():

    new Exception().printStackTrace();

    and then copy and paste us one of the stack traces -- it will let us know what is invoking dispose(). There may be a loop among several methods, and it might make sense in looking at the trace.


    [Jess in Action][AskingGoodQuestions]
    Andreas Pax Lück
    Greenhorn

    Joined: Nov 04, 2009
    Posts: 18
    This equals all the time:

    java.lang.Exception
    at client.gui.FileTransmissionDialog.dispose(FileTransmissionDialog.java:305)
    at client.gui.FileTransmissionDialog.cancelButtonActionPerformed(FileTransmissionDialog.java:382)
    at client.gui.FileTransmissionDialog.thisWindowClosed(FileTransmissionDialog.java:539)
    at client.gui.FileTransmissionDialog.access$6(FileTransmissionDialog.java:537)
    at client.gui.FileTransmissionDialog$7.windowClosed(FileTransmissionDialog.java:598)
    at java.awt.Window.processWindowEvent(Unknown Source)
    at javax.swing.JDialog.processWindowEvent(Unknown Source)
    at java.awt.Window.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Andreas Pax Lück
    Greenhorn

    Joined: Nov 04, 2009
    Posts: 18
    Thanks, my friends. Now, I found the really stupid bug in my code.

    Take a look at the stack trace: It's eye-catching that the handler method of the windows closed event invokes the handler method of the cancel button which triggers dispose. Usually, it cannot be possible that this is repeated all the time.

    But obviously, I created a loop with help of the windows closed handler. Following important (forgotten) method from the piece of code above creates this loop:



    Thanks for all your help. You showed me the possible area of the bug.

    Best regards


    Uncle PAX
     
    Consider Paul's rocket mass heater.
     
    subject: Disposing JDialog increases CPU usage up to 100%