Swing, unusual Windowmanagers and huge Preffered Sizes causing out of Heap Memory Errors

Just fixed a strange bug in my Swing Application: I had set the preferredSize of some Table in a ScrollPane to something huge, because it makes sense that it grows as large as possible (that might have been naive). Now, one user was reporting stuff like

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    <none of my classes in the stacktrace>

on both debian and archlinux, while it was running fine on my Ubuntu and Win32.

Turns out, it looks like his windowmanager – xfce – doesn't return maximum sizes for windows, and swing thinks it has infinite space to layout the window. Somehow that's causing the heap out of mem error…

Archives