Today I will bring a little bit of suggestion of GC (like promised in the last post). I will just give an idea of the types of Garbage Collector in Java and some (tons) references to good articles in the web to get more in depth ( I will put here also the depth details but it will be other post to make things easier to read =) ).
Just remembering the last post, the objects created are all placed in Young Generation where then when these objects become old and not removed from the GC, they become part of the Old generation (called Minor GC event). When the Old generation is full (or other metrics) it needs to be fully garbage collected (called Major GC). Also, most of the concepts here are more OpenJDK IceTea/Oracle Hotspot related, other JVM vendors might have different strategies.
Going back to the main point of thi article, the types of GC are:
- Serial - Very old single thread GC that was the default GC. After Java 5+ it ins`t default anymore due the low Throughput .
- Throughput Collector - Uses a parallel GC threads to clean the heap. There is two different options:-XX:+UseParallelOldGC and -XX:+UseParallelGC, where the UseParallelOldGC is to the algorithms clean the Tenured/Old space and the other one (UseParallelGC) is to the Young generation. This type has its name due it suits for high Throughput system where it needs intensive use of CPU and it tolerate some (like 1% of the) cases where the delay/latency is much higher than the useful (due the GC running).
- Concurrent Low Pause Collector - Collects (almost) concurrently, first with a very small stop-the-world event then it runs concurrently with the execution of the app (remember the other type above it run in parallel but it stopped your application and here your application is paused for short period). This is perfect for low latency applications (but it will consume more CPU,e.g.). Use the XX:+UseConcMarkSweepGC JVM`s option to enable it for Old generation (the young generation needs to run other algorithm with this one, it is complicated so I will explain in next post of the sequel).
- The Incremental - This is one GC type only found in old client JVMs where you could do some fine tunes. Today we have much more options to tune all the algorithms and also GC ergonomics (some refers will explain this, but there will be a post here also about it in the future).
I didn`t have time to create an image so, I would recommend to see the image from this blog for see the differences of the type I cited above (I will provide an update here and put an image here).
There are tons of keyword that might be new for your so I would recommend to see OpenJDK`s Glossary. That will help to get started and used to most of keywords that will help a lot to find the answer to your problems. For more details, to help to monitor and tune your JVM, I will leave you some references: