3 ms·
> It's been a while since I've done work in Java, but I'm pretty sure the GC is not to blame for this. Java uses a concurrent mark and sweep GC. Part of the pr
by mbell 15y ago
> It's been a while since I've done work in Java, but I'm pretty sure the GC is not to blame for this. Java uses a concurrent mark and sweep GC.
Part of the problem is that the default GC is not the ConcMarkSweep collector in most installations but rather its the parallel "stop the world" GC that is optimized for throughput, not latency. For web applications (or anything with latency issues) step one is almost always to modify your JVM opts to enable the CMS collector.
Unfortunately even the ConcMarkSweep collector can have issues. Its not that hard to create a workload that it can't handle resulting in your app slowing eating through all available heap space because the collector can't keep up ultimately forcing a full collection which on large heaps can be devastating, think 60 to 120 second pauses.
The G1 collector, which is no longer considered experimental in Java 7 is 'better' and you can specify a maximum pause time, but it can still run into situations where it has to force a full GC and there are situations where the CMS collector is still better.