Chapter 2. Java Virtual Machine Settings
The JVM's heap size determines how much memory is allowed for the application to consume, and is controlled by the following parameters:
- -Xms - Defines the minimum heap size allowed.
- -Xmx - Defines the maximum heap size allowed.
- -XX:NewRatio - Define the ratio between young and old generations. Should not be used if
-Xmn
is enabled. - -Xmn - Defines the minimum and maximum value for the young generation.
Xms
and Xmx
should be identical to prevent dynamic resizing of the heap, which will result in longer garbage collection periods.
The choice of garbage collection algorithm to use will largely be determined if throughput is valued over minimizing the amount of the time the JVM is fully paused. As JBoss Data Grid applications are often clustered it is recommended to choose a low pause collector to prevent network timeouts. The following parameters assume the CMS (Concurrent Mark-Sweep) collector is chosen:
- -XX:+UseConcMarkSweepGC - Enables usage of the CMS collector.
- -XX:+CMSClassUnloadingEnabled - Allows class unloading when the CMS collector is enabled.
- -XX:+UseParNewGC - Utilize a parallel collector for the young generation. This parameter minimizes pausing by using multiple collection threads in parallel.
- -XX:+DisableExplicitGC - Prevent explicit garbage collections.
Large, or Huge, Pages are contiguous pages of memory that are much larger than what is typically defined at the OS level. By utilizing large pages the JVM will have access to memory that is much more efficiently referenced, and memory that may not be swapped out, resulting in a more consistent behavior from the JVM. Large pages are discussed in further detail at Section 3.1, “About Page Memory”.
- -XX:+UseLargePages - Instructs the JVM to allocate memory in Large Pages. These pages must be configured at the OS level for this parameter to function successfully.
This parameter relates to JIT (Just-In-Time) compilation, which requires extended loading times during startup, but provides extensive compilation and optimization benefits after the startup process completes.
- -server - Enables server mode for the JVM.
2.1. Memory Requirements Copy linkLink copied to clipboard!
The default minimum amount of memory required to run JBoss Data Grid varies based on the configuration in use:
standalone.conf
- The server should have a minimum of 2 GB of RAM for a single JBoss Data Grid instance, as the default heap may grow up to 1.3 GB, and Metaspace may occupy up to 256 MB of memory.domain.conf
- The server should have a minimum of 2.5 GB of RAM for a single JBoss Data Grid managed domain consisting of two JBoss Data Grid server instances, as the heap may grow up to 512 GB for the domain controller, the heap for each server instance may grow up to 256 MB, and the Metaspace may occupy up to 256 MB of memory for the domain controller and each server instance.
There is no official memory recommendation for JBoss Data Grid, as the memory requirements will vary depending on the application and workload in use. As the heap is increased more data may be stored in the grid.
Each JVM process has a memory footprint that adheres to the following formula:
JvmProcessMemory = JvmHeap + Metaspace + (ThreadStackSize * Number of Threads) + Jvm-native-c++-heap
JvmProcessMemory = JvmHeap + Metaspace + (ThreadStackSize * Number of Threads) + Jvm-native-c++-heap
Jvm-native-c++-heap
will vary based on the native threads and if any native libraries are used; however, for a default installation it is safe to assume this will use no more than 256
MB of memory.