There are 2 options specify memory/heap size in java:
- -Xms: It sets initial (minimum) heap size for JVM. This means that when you start your program the JVM will allocate this amount of memory instantly.
- -Xmx: It sets maximum memory size that the heap can reach for the JVM.
Export Heap size in Linux:
$ export JAVA_OPTS="-Xms256m -Xmx512m"
Above command will set minimum heap size as 256MB, and maximum heap size as 512MB.
Set Heap size for tomcat in Linux:
Add following line in TOMCAT_HOME/bin/setenv.sh file
After adding restart your tamcat. It will will set minimum heap size as 512MB, and maximum heap size as 2048MB for your tomcat.