Skip to content

Tag: garbage-collection

Make ZGC run often

ZGC runs not often enough. GC logs show that it runs once every 2-3 minutes for my application and because of this, my memory usage goes high between GC cycles (as high as 90%). After GC, it drops to as low as 20%. How to increase GC run’s frequency to run more often? Answer -XX:ZCollectionInterval=N &#…

Java object garbage collection

I am working on the OCA Java certification and unsure of how to understand the answer to one question. The question is which object will be available for garbage collection after the //HERE point. The answer provided by the online test is : One object (o1). Can someone explain me why? Answer Consider a simple…

How to assert some Java method is garbage free?

I have a piece of code that (currently) use Java 8’s Optional and Stream. And we started having GC overhead issues since this code was deployed to production. See the gist of the code below (getters, constructors and overloads removed for clarity): While it could be unrelated, I’d like to make this code garba…