0

As I´m running into memory-problems running my web-app I want to know how I can set the memory for tomcat-8 running on an AWS-linux as a service.

GI-cat needs at least 1000MB free heap space to work properly. You have 506MB free (total 1752MB). Increase the memory if possible, by adding -Xmx1000m or more to the java arguments.

I´ve read How do I increase memory on Tomcat 7 when running as a Windows Service? but it only handles windows-services, not linux.

I suppose I have to manipulate catalina.sh, don´t it but I´m unsure if this will effect the service when using service tomcat8 restart.

Community
  • 1
  • 1
MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111

1 Answers1

0

Non-persistent method

You can set the environment variable before you start your tomcat service:

export CATALINA_OPTS="-Xmx1000m"

And then start your service with:

service tomcat8 restart

Side note: this variable is only set until it gets unset/set by another process or your linux box restarts.

Persistent method

To make this persistent, you want to modify tomcat.conf in $CATALINA_HOME/conf/ and append/modify the environment variable with:

CATALINA_OPTS="-Xmx1000m"

Ref: https://unix.stackexchange.com/a/244197

Updated #1: Changed the response to better suit the author's needs.

Community
  • 1
  • 1
Roger
  • 1
  • 1
  • But wouldn´t this affect all my other java-processes as well? I´m a bit reluctant on setting variables for the whole system, instead I just want to set it for that particular service. Nevertheless I´m looking for something more persistant so I won´t set it each time my host computer restarts. – MakePeaceGreatAgain Nov 02 '16 at 08:16
  • That's a valid concern. JAVA_OPTS affects all jvm, if you only have one tomcat running. You could set CATALINA_OPTS instead. – Roger Nov 02 '16 at 08:42
  • To find out the difference between JAVA_OPTS and CATALINA_OPTS you can take a look at http://stackoverflow.com/questions/11222365/catalina-opts-vs-java-opts-what-is-the-difference – Roger Nov 02 '16 at 08:44
  • And to make it persistent, there's also this post http://unix.stackexchange.com/a/244197. – Roger Nov 02 '16 at 08:45