Java / Java 17 Garbage Collection Interview Questions
Which is better for a low-latency trading application - ZGC or Shenandoah - and why?
Both target the same outcome - pause times that stay low and roughly constant regardless of heap size - which is exactly what a latency-sensitive trading system needs, but they get there through different mechanisms with different overhead profiles.
| Aspect | ZGC | Shenandoah |
| Mechanism | Colored pointers + load barriers | Brooks forwarding pointers + barriers |
| Per-object overhead | Bits within the reference itself | Extra native word per object |
| Pause scaling | Independent of heap size | Independent of heap size |
| JDK 17 maturity | Production-ready | Production-ready |
Neither is categorically faster for every workload - real-world results depend heavily on the specific object graph shape, allocation rate, and reference-access patterns of the application, which is exactly the kind of thing that varies between one trading engine and another. Availability can also be a deciding factor in practice: which of the two ships and is best supported can differ across JDK distributions and vendors.
The practical recommendation is to benchmark both directly against production-like load and message-processing patterns before committing, since a categorical answer would be overstating what either collector's design alone can promise - the design goals are aligned, but the winner in practice is workload-specific.
More Related questions...