Java difference between Xms and Xmx

 

There are 2 options specify memory/heap size in java:

  1. -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.
  2. -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

JAVA_OPTS="-Xms512m -Xmx2048m"

After adding restart your tamcat. It will will set minimum heap size as 512MB, and maximum  heap size as 2048MB for your tomcat.

-Sany

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s