Benchmarking the Garbage Collector
Choosing a garbage collector comes down three characteristics: throughput, latency, and memory footprint. Because you don’t have infinite resources, you’ll have to choose one of them.
It’s best to start by using the default collector. If you don’t experience any performance problems, then stick with it. If you begin to encounter problems, adjust the heap first. Use the 30% rule to find the optimal heap size. But remember, a heap that’s too small or too big can hurt performance.
If you’ve optimized your heap size and still have performance problems, only then should you consider changing the garbage collector. Depending on your overall heap size, try either the CMS or G1 collector. For large heaps, try G1. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access