Two ways to allocate memory for container JVM

There are two ways to allocate memory for container JVM.
Add parameters
to the startup command. Method 1: Add JVM memory parameters
java -Xms512m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=128m -jar test.jar

-Xms: minimum heap memory, default is 1/64 of physical memory
-Xmx: maximum heap memory, default is 1/4 of physical memory
-XX:PermSize non-heap memory initial value, default is 1/64 of physical memory
-XX :MaxPermSize Maximum non-heap memory size, the default is 1/4 of physical memory

Method 2: Configure sensing parameters to automatically sense container resource limits to allocate memory proportionally
java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2 -jar test.jar

-XX: MaxRAMFraction determines the maximum memory that can be allocated for JVM
-XX: MaxRAMFraction = 1 The maximum heap size is 1GB.
-XX: MaxRAMFraction = 2 The maximum heap size is 500MB.
-XX: MaxRAMFraction = 3 The maximum heap size is 250MB.
-XX: MaxRAMFraction = 4 is too small.

Guess you like

Origin blog.csdn.net/yucaifu1989/article/details/108107228