Image

Imagebanana wrote in Imagejava_dev

Dead thread

I have a Swing app where the user can re-size an image. If the user zooms in a few times the JVM quickly runs out of memory. The image sizing is done on the AWT event thread, but when an OutOfMemoryError is thrown this thread dies and the user can't do anything (including closing the app) because GUI events are no longer handled.

There are a few possible solutions.
  • I could do the re-sizing on another thread, but the problem is still lurking: an uncaught exception in the event thread should still be handled gracefully.
  • I could have a thread that polls to see if the event handler is alive and have that clean up, but this feels clunky.
  • I've tried setting the system property sun.awt.exception.handler having read how this is supposed to handle exactly this problem, but it doesn't seem to work.
Any other suggestions?

Edit: Naturally, as soon as I posted this I found a possible solution: http://www.javaspecialists.co.za/archive/Issue081.html and http://www.javaspecialists.co.za/archive/Issue089.html