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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.