N/APosted on - 09/11/2011
I am using Tomcat for my application development. I have deployed one web application. When I start the server the error mentioned below appears in the command prompt. The server does not start at all.
“java.lang.RuntimeException: Unable to create engine instance – class path be wrong, or contain invalid contents
Exception in thread "Low Memory Detector" java.lang.OutOfMemoryError: PermGen space”
Screen shot of the error message.
I have changed the JAVA_OPTs as follows;
set JAVA_OPTS=%JAVA_OPTS% -Xms64m -Xmx64m -XX:PermSize=32m -XX:MaxPermSize=32m
I cannot spare a lot of memory for this development application, so am trying to find the best RAM requirement for the server. I have the following two questions:
What is the minimal RAM I need to put for a JVM in the Tomcat server?
How do I measure the optimum for my application in Tomcat, so that I can put only the required amount in the JAVA_OPTs?
Tomcat server does not start after JAVA_OPT change
First, you have to know that "java.lang.OutOfMemoryError: PermGen space" error is caused by your -XX:PermSize and -XX:MaxPermSize options. So for this error, you should increase the value of those options.
Fyi, -XX:PermSize and -XX:MaxPermSize are used to set PermGen space which are used for things that do not change (or change often) e.g. Java classes. So often large, complex apps will need lots of PermGen space. Also note that Xmx is separate from the PermGen space, so increasing Xmx will not help with the PermGen errors.
These are answers to your question:
Tomcat itself can run with only 20-60 MB of memory. But you also need to consider the need of your app going to be deployed.
Compare free memory of your server when the app is not running (peak usage) and when it's not running. Set the difference value as -Xmx. And for -XX:PermSize and -XX:MaxPermSize, put the difference between free memory when the app just starting and when it's not running. There are some ways to do this:
Using built-in feature of OS (e.g. free -m command in Linux);
Creating a jsp that print out result of java.lang.Runtime.getRuntime().freeMemory() and java.lang.Runtime.getRuntime().totalMemory();
Installing java-profiling tools (e.g. jProbe, Yourkit).
Hope it helps.