Skip to content

Commit c41eeb6

Browse files
authored
Update README.md
1 parent 5120dfe commit c41eeb6

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Some of my favorite articles on the subject include (if you are new to GC tuning
3737
+ [Garbage Collectors Available In JDK 1.7.0_04](http://www.fasterj.com/articles/oraclecollectors1.shtml)
3838
+ [1.4.1 Garbage collection algorithms](http://www.javaperformancetuning.com/news/qotm026.shtml)
3939
+ [Understanding CMS GC Logs](https://blogs.oracle.com/poonam/entry/understanding_cms_gc_logs)
40+
+ [Garbage Collection Optimization for High-Throughput and Low-Latency Java Applications](https://engineering.linkedin.com/garbage-collection/garbage-collection-optimization-high-throughput-and-low-latency-java-applications)
41+
+ [Calculator](http://www.curiousmentality.co.uk/2011/11/tuning-jvm-memory-settings/)
42+
+ [Useful JVM flags](https://blog.codecentric.de/en/2012/08/useful-jvm-flags-part-5-young-generation-garbage-collection/)
4043

4144
The young and old generation use different types of algorithms for garbage collection. The young generation uses a copying collection algorithm that moves all the live object from one area to another, leaving the dead objects behind. The old generation uses a mark-and-sweep collection algorithm. Copy collection time is roughly proportional to the number of live objects, mark-and-sweep collection is roughly proportional to the size of the heap. This is why the young heap is small and collected frequently and the old heap is big and collected less frequently.
4245

@@ -49,7 +52,16 @@ On a multicore machine the choice is between the parallel algorithm and the conc
4952
+ Parallel: use when optimizing for throughput, therefore your system will be able to process more requests, but stop-the-world pauses will be more noticeable.
5053
+ Concurrent: use when optimizing for latency, therefore your system will produce more consistent, but slower results.
5154

52-
On all the systems I've worked on, consistency is more important so I normally use the concurrent algorithm. The concurrent algorithm only works on the old generation, but the parallel algorithm will be defaulted for the new generation. To enable the concurrent algorithm use the flag:
55+
On all the systems I've worked on, consistency is more important so I normally use the concurrent algorithm. The concurrent algorithm only works on the old generation, but the parallel algorithm will be defaulted for the new generation.
56+
57+
ParNew collects the new generation. It is a copying collector which uses multiple GC threads. Concurrent Mark Sweep collects the tenured generation. Performs the following phases:
58+
+ Initial Mark (stop the world)
59+
+ Concurrent Marking
60+
+ Remark (stop the world)
61+
+ Concurrent Sweep
62+
+ Resetting
63+
64+
To enable the concurrent algorithm use the flag:
5365

5466
```
5567
-XX:+UseConcMarkSweepGC
@@ -88,3 +100,20 @@ To check if a flag is set by default:
88100
```
89101
java -XX:+PrintFlagsFinal | grep FLAG
90102
```
103+
104+
Random example:
105+
```
106+
java -XX:+PrintFlagsFinal -version
107+
108+
-Xms8g
109+
-Xmx8g
110+
-XX:NewSize=6g
111+
-XX:SurvivorRatio=20
112+
-XX:+UseConcMarkSweepGC
113+
-verbose:gc
114+
-XX:+PrintGCDetails
115+
-XX:+PrintGCDateStamps
116+
-XX:+PrintGCTimeStamps
117+
-XX:+PrintTenuringDistribution
118+
-Xloggc:/var/log/uni/gc.log
119+
```

0 commit comments

Comments
 (0)