Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restricting JVM not to invoke GC

How exactly JVM determines that it should Garbage Collector?Is there any way to restrict JVM not to invoke GC?

like image 283
GD_Java Avatar asked Mar 27 '13 07:03

GD_Java


2 Answers

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().

like image 108
Stephen C Avatar answered Sep 25 '22 23:09

Stephen C


You cannot tell the JVM not to invoke GC, but you can tell the JVM to ignore calls to System.gc() via -XX:+DisableExplicitGC.

like image 39
Axel Avatar answered Sep 24 '22 23:09

Axel