There is a nasty memory leak when serving large PDFs from GFv2.
Starting Sun Java System Application Server 9.1 (build b58g-fcs) (latest download from GF homepage).
I am trying to simply view a 139MB PDF file from Glassfish.
Bone stock default GF install on Mac OS 10.4, JDK 1.5
Create a simple webapp from NetBeans, with the generated index.jsp. Add in your large PDF file.
Start Glassfish, and deploy your war.
Launch JConsole, connect to GF, and select the Memory pane.
On my system, after a quick "Perform GC" click, the JVM is around 29MB.
Go to a brower and try to download the pdf file:
Observe on JConsole the memory shoot up from 29MB up to ~190MB.
Observe in Glassfish Log File:
be7b-dfbb06936407;|StandardWrapperValve[default]: PWC1406: Servlet.service() for servlet default
java.lang.OutOfMemoryError: Java heap space
be7b-dfbb06936407;|java.lang.OutOfMemoryError: Java heap space
Click "Perform GC" on JConsole, and observe the JVM Heap size go down by only a couple of MB (say
from 190MB to 188MB).
Try and download the PDF again from the browser, and observe the JVM memory surge up again, and
again hit OutOfMemory, and again not be able to GC any of the memory.
Go ahead and stop GF, it's effectively dead now anyway.
I have observed similiar behavior on Solaris installs, but of earlier build (GF Release Candidates).
I have not tried this with other large resources (say a large ZIP).
This is a real show stopper for us.