Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM heap parameters

After reading already asked question on the subject and a lot of googling I am still not able to have a clear view of -Xms option

My question is: what's the difference between java -Xms=512m -Xmx=512m and java -Xms=64m -Xmx=512m?

For now I have the following answer:

The only difference is in the number of garbage collections that will be run during my application's run and the number of memory allocations. Am I right ?

Here are my reasons for this answer:

Setting the -Xms option to 512m doesn't result in my application using really 512M of physical memory after startup. I guess this is related to modern OS virtual memory management and lazy pages allocations. (I noticed that setting -Xms to 512M or to 64M doesn't change at all the initial used memory reported either by top on Linux or by the task manager on windows)

Can someone help me to understand the impact of this Xms option or point me to links that will help me to understand it?

Thanks in advance

Manu

like image 918
Manuel Selva Avatar asked Jul 08 '09 14:07

Manuel Selva


People also ask

What are the JVM parameters?

Now let's discuss the most frequently used JVM Parameters which are 3 namely as follows: Java Heap Size. Garbage Collector. Print GC.

What is Xms and XMX parameter?

The flag Xmx specifies the maximum memory allocation pool for a Java virtual machine (JVM), while Xms specifies the initial memory allocation pool. The Xms flag has no default value, and Xmx typically has a default value of 256 MB. A common use for these flags is when you encounter a java.

Which JVM parameter sets maximum heap size?

Use the information on JVM parameter values on the mqsichangeproperties command to set the heap size that you require.

What is the default heap size of JVM?

The Java™ virtual machine (JVM) heap size setting directly relates to how many server instances can be started within a dynamic cluster on a specific node. You might need to modify the JVM heap size setting based on your environment configuration. The default value is 256 MB.


1 Answers

The JVM will start with memory useage at the initial heap level. If the maxheap is higher, it will grow to the maxheap size as memory requirements exceed it's current memory.

So,

  • -Xms512m -Xmx512m

JVM starts with 512 M, never resizes.

  • -Xms64m -Xmx512m

JVM starts with 64M, grows (up to max ceiling of 512) if mem. requirements exceed 64.

like image 84
Steve B. Avatar answered Sep 29 '22 05:09

Steve B.