Java.lang.OutOfMemoryError: Java heap space in tomcat7

I get this error on tomcat server.

Exception in thread "http-bio-8080-exec-17" Exception in thread "http-bio-8080-exec-2" Exception in thread "http-bio-8080-exec-15" Exception in thread "http-bio-8080-exec-20" Exception in thread "http-bio-8080-exec-18" java.lang.OutOfMemoryError: Java heap space. 

I saw MAT, but how do I generate the .hprof file on my Tomcat server.

Thanks.

+8
java tomcat7
source share
3 answers

to remove the error, edit the file

 /etc/default/tomcat7 

replaced by:

 JAVA_OPTS="-Djava.awt.headless=true -Xmx1280m -XX:+UseConcMarkSweepGC" 

Then restart the web server.

Xmx is the new maximum memory size and should be available to your machine.

+14
source share

add this line to /path/to/tomcat/bin/setenv.sh (if it does not exist):

 CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m" 

this increases the tomcat heap size to 1024 MB.

+11
source share

Solution according to your OS:

if Ubuntu :

open the .bashrc file in the user's home folder (it is hidden) and add or edit one line from the last 2-3 lines:

 export CATALINA_OPTS="-Xms512m -Xmx1024m" 

else Windows :

In your environment, variables add / edit

 CATALINA_OPTS = "-Xms512m -Xmx1024m" 
+5
source share

All Articles