Posted by plethora
on June 9, 2006 at 1:52 PM PDT
First, is there a good description available on how the sun.java2d.Disposer class works in Java 1.5.0?
Second, I think I've found a possible reference leak.
1) A console-only application is started.
2) After 10 minutes of running, a thread dump does NOT show any Java2D Disposer thread.
3) After 20 minutes of running, a background image is created using Java2D, and sent over the network. (The image is never shown on screen, the app is still running in console mode)
4) After (3) above, a new thread can be seen in the thread dump (the sun.java2d.Disposer thread).
Now, the original thread that started the offline rendering had a couple of InheritableThreadLocals set. I don't know how/where the disposer thread is created, but it appears that it (as you would guess) inherits the InteritableThreadLocals of the thread that caused Java2D to be (lazily?) initialized.
Of course, one of the InheritableThreadLocals (indirectly) references a ClassLoader that has 2GB of memory attached. Later in the application lifecycle, this prevents garbage collection, and triggers a memory overflow (OOM).