how to increase tomcat memory size in linux

How To Set Java Heap Size On Tomcat Server Linux

Java process needs memory to run the applications. So, we can set or increase the java heap size memory in tomcat 8 as well as another version. JVM divides the memory into heap and stack size. Java objects resides within the area called a heap. The heap is made when JVM starts up and that they can increase or decrease within the size while applications run.

Check Out: How To Apply SSL Certificate On Load Balancer On Amazon Cloud

We can use -Xms<size> and -Xmx<size> parameter to line the heap size in tomcat server file. We will define these parameters in the catalina.sh or we can also create a file setenv.sh under <tomcat home direcroty>/bin directory and don’t forget to form it executable.

chmod +x setenv.sh

export CATALINA_OTPS=”$ CATALINA_OTPS -Xms256m”

export CATALINA_OTPS=”$ CATALINA_OTPS -Xmx256m”

export CATALINA_OTPS=”$ CATALINA_OTPS -XX:MaxPermSize=256m”

-Xms<size> = Initial Size

-Xmx<size> = Maximum Size

There’s an alternative choice available to line the java thread stack size using -Xss<size> but don’t forget to use M or G at the end of the size.

Check Out: How To Install and Configure Node Exporter Prometheus

You can set using the command line. Heap Size 256 here just for demonstration and therefore the size depends on your system RAM memory. Make sure both the initial and maximum value should match. so

You can simply use these parameters in the catalina.sh file using JAVA_OPTS= “-Xms256m -Xmx256m”

export CATALINA_OTPS= -Xms256m -Xmx256m;

The server can run out of various sorts of memory permanent generation. If you’re running multiple applications on the equivalent servers. You’ll set these parameters.

If you face error like java.lang.OutOfMemoryError: PermGen space

Check Out: Docker Connection Error Desc Transport X509 Certificate

we can also use these parameters:-

-Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:MaxNewSize=256m

-XX:PermSize= it’s used to set the permanent generation where it stores the class files. so

Save the file and restart the tomcat server. so

You’re done set java heap memory increase tomcat 8 memory

LEAVE A REPLY

Please enter your comment!
Please enter your name here