JAVAGeek
JAVAGeek

Reputation: 2794

Set maximum heap space for tomcat

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 ?

Upvotes: 0

Views: 3503

Answers (3)

user1590355
user1590355

Reputation:

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

Upvotes: 2

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34516

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

JVM_ARGS="-Xmx64m"

Regards

Philippe

Upvotes: 1

Adel Boutros
Adel Boutros

Reputation: 10285

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

Upvotes: 1

Related Questions