I’ve been having some trouble with a server running Tomcat6 on Ubuntu with a Spring/Hibernate set up. It also does some image resizing via Image Magick.
The problems were that the perm gen size for the Hibernate objects was too small and it ended up running out of memory.
No problem, in Ubuntu, the fix was going /etc/default/tomcat6 and editing the JAVA_OPTS variable.
I started off with
That solved the Hibernate problem but I was soon getting out of memory errors for image uploads. I had to add this into the file
JAVA_OPTS="-XX:MaxPermSize=512m -Xms256m -Xmx512m"
Running this gave me some useful feedback about the memory that Java was using.
jmap -heap <pid>
There are some useful resources out there for anyone interested in reading more