How to force garbage collection in Java?

后端 未结 22 1526
离开以前
离开以前 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:53

    Using the Java™ Virtual Machine Tool Interface (JVM TI), the function

    jvmtiError ForceGarbageCollection(jvmtiEnv* env)
    

    will "Force the VM to perform a garbage collection." The JVM TI is part of the JavaTM Platform Debugger Architecture (JPDA).

提交回复
热议问题