Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between xmx and MaxRAM JVM parameters?

MaxRAM:

based on the amount of memory on the machine. The proportion of memory to use for the heap is controlled by the command-line options InitialRAMFraction and MaxRAMFraction [...] The value of MaxRAM is platform-dependent.

Xmx:

-Xmxn Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts.

As I understand both define heap size. No? What is recommended to use: Xmx or MaxRAM? If I use both which one ovverides another?

like image 918
Cherry Avatar asked Jan 07 '19 09:01

Cherry


People also ask

What is the significance of Xms and XMX as JVM parameters?

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.

What is Xms and XMX while starting JVM?

The flag Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms specifies the initial memory allocation pool. This means that your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory.

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.


1 Answers

-Xmx specifies the precise upper limit for the heap. It is the preferred way to set the heap size.

-XX:MaxRAM does not define the heap size directly. Instead this parameter overrides the actual amount of physical RAM when calculating the heap limits basing on ergonomics.

If -Xmx is set, MaxRAM is never used. Otherwise the maximum heap size is estimated1 as

MaxHeapSize = MaxRAM * MaxRAMPercentage / 100% (default MaxRAMPercentage=25)

1 The actual algorithm is a bit more complicated and depends on other parameters.

like image 192
apangin Avatar answered Oct 27 '22 10:10

apangin