The main research in this article is the relevant content of detailed explanation of flag settings in JVM, which is introduced as follows.
-Xmx3550m: Set the maximum available memory of JVM to 3550M.
-Xms3550m: Set the initial available memory of JVM to 3550M.
-Xmn2g: Set the size of the young generation to 2G.
-Xss128k: Set the stack size of each thread to 128K
-XX:NewSize=4: Set the size of the young generation to 4
-XX:NewRatio=4: Set the ratio of the young generation (including Eden and two Survivor areas) to the old generation (excluding the persistent generation) to 4, then the ratio of the young generation to the old generation is 1:4, and the young generation accounts for 1/5 of the entire stack
-XX:SurvivorRatio=4: Sets the size ratio between the Eden area and the Survivor area in the young generation. Set to 4, the ratio between the two Survivor areas and one Eden area is 2:4, and one Survivor area accounts for 1/6 of the entire young generation.
-XX:MaxPermSize=16m: Set the persistent generation size to 16m.
-XX:PretenureSizeThreshold=n, objects greater than n are placed directly into the old age
-XX:MaxTenuringThreshold=0: Set the maximum age of garbage. If set to 0, the young generation object will not pass through the Survivor area and directly enter the old generation.
-XX:+UseParallelOldGC: Configure the old generation garbage collection method to parallel collection.
Whole heap size = Young Generation Size + Old Generation Size + Persistent Generation Size.
-XX:+UseSerialGC: Set the serial collector
-XX:+UseParallelGC: Set the parallel collector
-XX:+UseParalledlOldGC: Set up parallel old generation collector
-XX:+UseConcMarkSweepGC: Set up the concurrent collector
-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-Xloggc:filename
-XX:ParallelGCThreads=n: Set the number of CPUs used when collecting the parallel collector. The number of threads collected in parallel.
-XX:MaxGCPauseMillis=n: Set the maximum pause time for parallel collection
-XX:GCTimeRatio=n: Set the percentage of garbage collection time to program running time. The formula is 1/(1+n)
-XX:+CMSIncrementalMode: Set to incremental mode. It is suitable for single CPU situations.
-XX: ParallelGCThreads=n: Set the number of CPUs used when the young generation of the concurrent collector is parallel collection. The number of threads used in parallel collection.
Suppose there is a file named TestMem.java
javac TestMem.java java -verbose:gc -Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8 TestMem
-Xms20M: The initial size of the Java heap in JVM is 20M. (Including the new generation and the elderly)
-Xmx20M: The maximum size of the Java heap in JVM is 20M, which means it is not scalable. (Including the new generation and the elderly)
-Xmn10M: The size of the new generation is 10M
-XX:+PrintGCDetails: Print detailed GC information
-XX:SurvivorRatio=8: The spatial ratio of one Enden to one Survivor area in the new generation is 8:1, then the ratio of two Survivor areas to one Eden area is 2:8, and one Survivor area accounts for 1/10 of the entire young generation
After knowing the above flag information, we can get the following information:
The total size of the java heap is 20M = 20 * 1024K = 20480K
The size of the Ceponymous generation: 10M = 10 * 1024K = 10240K
eden space: 10240K * 8/10 = 8192K
from space: 10240K * 1/10 = 1024K
to space: 10240K * 1/10 = 1024K
Size of the old age: 20M - 10M = 10M = 10240K
The above is all the detailed explanation of the flag settings in JVM in this article, I hope it will be helpful to everyone. Interested friends can continue to refer to other related topics on this site. If there are any shortcomings, please leave a message to point it out. Thank you friends for your support for this site!