How to force garbage collection in Java?

后端 未结 22 1517
离开以前
离开以前 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 00:51

    The best (if not only) way to force a GC would be to write a custom JVM. I believe the Garbage collectors are pluggable so you could probably just pick one of the available implementations and tweak it.

    Note: This is NOT an easy answer.

提交回复
热议问题