Reputation: 2201
I am running my spring application in tomcat7 with below bin config,
#!/bin/sh
#
CATALINA_HOME=/usr/share/tomcat7
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in $DEFAULT)
JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm"
# Look for the right JVM to use
for jdir in $JDK_DIRS; do
if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
JAVA_HOME_TMP="$jdir"
# checks for a real JDK like environment, needed to check if
# really the java-gcj-compat-dev package is installed
if [ -r "$jdir/bin/jdb" ]; then
JAVA_HOME="$JAVA_HOME_TMP"
fi
fi
done
CATALINA_OPTS="-server -Xms512M -Xmx512M -XX:+UseG1GC"
# Default Java options
if [ -z "$JAVA_OPTS" ]; then
#JAVA_OPTS="-Djava.awt.headless=true -Xmx128M"
JAVA_OPTS="-server -Xms512M -Xmx512M -XX:+UseG1GC"
fi
But still I am facing "java.lang.OutOfMemoryError: GC overhead limit exceeded".
where am I doing mistake?
Upvotes: 0
Views: 2572
Reputation: 131316
For this kind of error, Java tools provide all mechanisms to capture important information. Without using it, it may be complicated and time wasting. If your problem is reproductible i advise you to enable the memory debug flags when you run your java process and try to reproduce your problem.
In a first time, I propose you to add in your catalina opts :
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heapDumpOOME.log
It will create a heap dump when the OutOfMemory Error is thrown and it's free because it consumes resources and CPU only if the error happens.
If it's not enough, enable the GCC logs to have more information on usage memory and the way gcc has worked during the app running.
Look at https://confluence.atlassian.com/confkb/how-to-enable-garbage-collection-gc-logging-300813751.html.
It explains how to do it in Tomcat.
With it, you should have precise pointers on the cause of your memory lack.
Upvotes: 1