0

My Java EE application runs just fine on host server , but it uses a lot of heap space . allowed heap space is 64MB. I am getting my hosting account suspended every time my app uses more then 64 MB heap. I think the hosting provider has not set the max heap space for my app , that is why i am not getting the outOfMemoryException on reaching >64MB.

I have my own instance of tomcat, i can configure tomcat configurations. My question is - how can i set the max allowed heap space for my tomcat instance so that it throws outOfMemoryException on reaching the limit ? that way my hosting account will not get suspended.

here is the catlina.bat and catlina.sh

where do i have to make changes in these files ?

trincot
  • 317,000
  • 35
  • 244
  • 286
JAVAGeek
  • 2,674
  • 8
  • 32
  • 52
  • 1
    This has been discussed many times, for example see http://stackoverflow.com/questions/286007/how-to-tune-tomcat-5-5-jvm-memory-settings-without-using-the-configuration-progr – Petr Aug 10 '12 at 13:26

3 Answers3

2

Increasing the heap space is simple as adding a command line switch to the JVM :

-Xmx2g

2g for 2Gb, if you want in megabyte : 512m ---> -Xmx512m

1

You have a variable called JAVA_OPTS.

Add to it the argument -Xmx1g.

Replace: set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"

with: set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" -Xmx1g

Adel Boutros
  • 10,205
  • 7
  • 55
  • 89
1

It is in setenv.sh which will be detected by catalina.sh:

JVM_ARGS="-Xmx64m"

Regards

Philippe

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116