You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+[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)
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.
42
45
@@ -49,7 +52,16 @@ On a multicore machine the choice is between the parallel algorithm and the conc
49
52
+ 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.
50
53
+ Concurrent: use when optimizing for latency, therefore your system will produce more consistent, but slower results.
51
54
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:
53
65
54
66
```
55
67
-XX:+UseConcMarkSweepGC
@@ -88,3 +100,20 @@ To check if a flag is set by default:
0 commit comments