Java / GraalVM Interview questions
When would you choose GraalVM Enterprise's G1 GC support over Community's Serial GC for native image?
Serial GC, the Community Edition default for native images, uses a single thread for collection work and keeps metadata overhead minimal - which is ideal for small heaps and short-lived processes where a GC pause simply doesn't have time to matter much.
G1 GC (available via Oracle GraalVM) is a generational, region-based, mostly-concurrent collector designed to keep pause times predictable even as heap size grows into the multi-gigabyte range - something Serial GC's single-threaded, stop-the-world approach handles increasingly poorly as heaps get larger.
| Choose Serial GC when | Choose G1 GC when |
| Heap is small, process is short-lived (CLI tool, quick function) | Heap is large, process is long-running (persistent microservice) |
| Minimal memory overhead is the priority | Predictable pause times under sustained load matter more than minimal overhead |
In short: pick G1 once your native-image service behaves more like a long-lived server than a quick, disposable process.
More Related questions...