Not until recently did I find that Java 11 has introduced a no-op garbage collector, which essentially does nothing. Configuring the Java runtime with this garbage collector essentially disables garbage collection.
Also to be noted is the fact that until Java 11, there is no way to disable garbage collection. That makes sense as for someone like me who have been using Java for the last 20 years, since version 1.2, I was never faced with a situation where there was a need to disable GC. Java does not have an option to deallocate memory. If GC is disabled, who will free up the memory that got allocated through new object creations?
So why now was I looking to disable garbage collection now?
Well, we were into micro-services implementation and experimenting with GraalVM and micro-services frameworks.
Our objective is to spin up services as quickly as possible and replace a running instance when any of our monitored parameters starts showing any sign of weakness.
The obvious problem with Java garbage collection showed its head in our deliberations. If Java stops everything when it does garbage collection, why not
- Disable the garbage collection
- Stop the instance when memory usage goes beyond a threshold
- Spin up a new instance to handle the low
Sounded by a good option to try
EpsilonGC is the no-ops GC introduced with Java 11. This can be enabled by starting the runtime with configuration flags
-XX:+UseEpsilonGC
and
-XX:+UnlockExperimentalVMOptions
Complete EpsilonGC specification can be found at JEP-318
No comments:
Post a Comment