How exactly JVM determines that it should Garbage Collector?Is there any way to restrict JVM not to invoke GC?
How exactly JVM determines that it should Garbage Collector?
It depends.
If you are using the throughput collector, then the JVM runs the GC when it cannot allocate a new object in the space (or one of the spaces) where it needs to be allocated.
If you are using a low pause collector, then the JVM triggers the GC when the free space ratio drops bellow a configurable level.
Is there any way to restrict JVM not to invoke GC?
No. If the JVM decides it needs to run the GC, it will run it. The only thing you can do is tell the JVM to ignore application code calls to System.gc()
.
You cannot tell the JVM not to invoke GC, but you can tell the JVM to ignore calls to System.gc()
via -XX:+DisableExplicitGC
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With