0

Is there a good way to force garbage collection manually in Java?

Are methods like System.gc() and Runtime.gc() guaranteeing that garbage collection will happen at the time it calls?

Sandeepa
  • 3,457
  • 5
  • 25
  • 41

1 Answers1

2

No, there is no way to manually force Java GC with 100% probability.

Moreover you can have a GC which does no actual work e.g. JEP 318 Epsilon, A No-Op Garbage Collector.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111