Difference between system.gc() and runtime.gc()

前端 未结 7 892
谎友^
谎友^ 2020-12-12 19:15

What is the difference between System.gc() and Runtime.gc()?

7条回答
  •  没有蜡笔的小新
    2020-12-12 19:38

    Both are same. System.gc() is effectively equivalent to Runtime.gc(). System.gc()internally calls Runtime.gc().

    The only difference is System.gc() is a class method where as Runtime.gc() is an instance method. So, System.gc() is more convenient.

提交回复
热议问题