When does System.gc() do something?

后端 未结 16 2253
傲寒
傲寒 2020-11-22 05:02

I know that garbage collection is automated in Java. But I understood that if you call System.gc() in your code that the JVM may or may not decide to perform ga

16条回答
  •  我在风中等你
    2020-11-22 05:43

    If you want to know if your System.gc() is called, you can with the new Java 7 update 4 get notification when the JVM performs Garbage Collection.

    I am not 100% sure that the GarbageCollectorMXBean class was introduces in Java 7 update 4 though, because I couldn't find it in the release notes, but I found the information in the javaperformancetuning.com site

提交回复
热议问题