Video in progress

What is Epsilon GC, and where might you need a GC that does not reclaim memory at all?

Epsilon (JDK 11, JEP 318) allocates memory but never collects it. When the heap runs out, the JVM stops with an OOM. It is useful in performance tests to isolate the effect of GC, to measure allocation, and for very short-lived processes.

📖 Answer

To turn it on:

java -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xmx4g -jar tool.jar

There are no GC threads, no barriers and no pauses. Allocation is a plain pointer bump in the TLAB.

Where it is useful:

  • A baseline in benchmarks. You compare how fast the code runs with and without GC. The difference is the real cost of the GC (barriers included).
  • Checking allocation. To test the claim "this code creates no objects at all": run it for a long time with Epsilon on a small heap. If it survives, it really doesn't allocate. If it crashes, there is allocation somewhere.
  • Short processes. A CLI utility or job runs for 2 seconds and finishes, and it fits in the heap. There is no need for a GC: the OS takes everything back when the process ends.
  • Latency experiments. In some trading systems there is the idea of fitting a day's work into a big heap and restarting at night. This is exotic and risky.

Why not for an ordinary service: running out of heap is only a matter of time, and it crashes with OutOfMemoryError.

Note: Epsilon is still behind an experimental flag, so if you see it on prod, ask why. In an interview this question usually leads into a conversation about "how do you measure the cost of GC".