How to force garbage collection in Java?

后端 未结 22 1789
离开以前
离开以前 2020-11-22 00:31

Is it possible to force garbage collection in Java, even if it is tricky to do? I know about System.gc(); and Runtime.gc(); but they only suggest t

22条回答
  •  深忆病人
    2020-11-22 01:14

    JVM specification doesn't say anything specific about garbage collection. Due to this, vendors are free to implement GC in their way.

    So this vagueness causes uncertainty in garbage collection behavior. You should check your JVM details to know about the garbage collection approaches/algorithms. Also there are options to customize behavior as well.

提交回复
热议问题