Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Xms and Xmx and XX:MaxPermSize

What the difference between

-Xms4096m
-Xmx2048M 
-XX:MaxPermSize=712M

I am getting confused of this two -Xmx2048M and -XX:MaxPermSize=712M

and will happen if I use -Xmx2048M or -Xmx2048m

like image 846
Sanjay Dutt Avatar asked Jul 12 '16 13:07

Sanjay Dutt


People also ask

What is the difference between XMS and XMX?

Xms is minimum heap size which is allocated at initialization of JVM in java. Xmx is the maximum heap size that JVM can use. It will set the minimum heap size of JVM to 512 megabytes.

Should I set XMS to XMX?

Oracle recommends setting the minimum heap size ( -Xms) equal to the maximum heap size ( -Xmx) to minimize garbage collections.

What is Permsize and Maxpermsize?

The perm size should be set to 1024 Megabytes. The maximum perm size should be set to 1024 Megabytes. Oracle recommends that -Xmn and -Xmx be set to the same value. This eliminates potentially costly heap reallocations, and can reduce the amount of heap fragmentation that can occur.

What is Max perm size in Tomcat?

Run the tomcat6w application Click the Java tab. Edit the values in the Java Options box. The following settings allocate 2 GB memory to the start Java heap, 6 GB for the maximum heap size, 128 MB for the permgen space and 256 MB for the maximum permgen size.


1 Answers

Java objects reside in an area called the heap, while metadata such as class objects and method objects reside in the permanent generation or Perm Gen area. The permanent generation is not part of the heap.

The heap is created when the JVM starts up and may increase or decrease in size while the application runs. When the heap becomes full, garbage is collected. During the garbage collection objects that are no longer used are cleared, thus making space for new objects.

-Xmssize Specifies the initial heap size.

-Xmxsize Specifies the maximum heap size.

-XX:MaxPermSize=size Sets the maximum permanent generation space size. This option was deprecated in JDK 8, and superseded by the -XX:MaxMetaspaceSize option.

Sizes are expressed in bytes. Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes.

References:

How is the java memory pool divided?

What is perm space?

Java (JVM) Memory Model – Memory Management in Java

Java 7 SE Command Line Options

Java 7 HotSpot VM Options

like image 103
JRL Avatar answered Sep 28 '22 02:09

JRL