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. ...

Get Deploying with JRuby 9k now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.