I have a web application running on Ubuntu 10 x64 and I keep receiving out of memory errors. The installation guide for the application indicates that the following line should be place in /etc/default/tomcat6
I have 1.5 GB of RAM on the machine but whenever I try to add that line, tomcat refuses to start with an error of:
# A fatal error has been detected by the Java Runtime Environment:
# java.lang.OutOfMemoryError: requested 787536 bytes for Chunk::new. Out of swap space?
The closest I can get is the following:
JAVA_OPTS="-Djava.awt.headless=true -Xmx512m -Xms512m -XX:MaxPermSize=256m -server"
Even trying to move to 768MB with the following line fails:
JAVA_OPTS="-Djava.awt.headless=true -Xmx768m -Xms768m -XX:MaxPermSize=512m -server"
I'm a little confused as to why as there is 1.4 GB (1467008 B) of RAM free before starting Tomcat according to free:
total used free shared buffers cached
Mem: 1573600 106592 1467008 0 0 0
-/+ buffers/cache: 106592 1467008
Swap: 0 0 0
Can anyone provide me with some pointers on how best to proceed?
When a JVM crashes, the first thing you should generally do is try a different JVM. Probably 90% of the time, the bug will go away. It will probably be replaced by other bugs, but as long as they're not bugs that bite YOU, that's good enough.
It's possible that you don't have enough memory available in the OS, though. The JVM memory settings apply only to the JVM itself, and the JVM has to fit within the memory constraints of the OS. Especially if you have swapping turned off this can sometimes be a problem.
Sources may include data from the Fakebook Research Foundation with support from Gargle University