Posted onEdited onInGarbageCollectionViews: Disqus: Symbols count in article: 1.4kReading time ≈3 mins.
Intro Java Garbage Collection Algorithms
這篇介紹Intro Java Garbage Collection Algorithms。
Java8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
default 使用 Parallel garbage collection Simimar to serial GC, It uses mark-copy in the Young Generation and mark-sweep-compact in the Old Generation. Multiple concurrent threads are used for marking and copying / compacting phases. You can configure the number of threads using -XX:ParallelGCThreads=N option.
Parallel Garbage Collector is suitable on multi-core machines in cases where your primary goal is to increase throughput by efficient usage of existing system resources. Using this approach, GC cycle times can be considerably reduced.
default 使用 G1 garbage collection The G1 (Garbage First) garbage collector was available in Java 7 and is designed to be the long term replacement for the CMS collector. The G1 collector is a parallel, concurrent, and incrementally compacting low-pause garbage collector.
This approach involves segmenting the memory heap into multiple small regions (typically 2048). Each region is marked as either young generation (further devided into eden regions or survivor regions) or old generation. This allows the GC to avoid collecting the entire heap at once, and instead approach the problem incrementally. It means that only a subset of the regions is considered at a time.