Difference between system.gc() and runtime.gc()
From looking at the source code: System.gc()
is implemented as
Runtime.getRuntime().gc();
So it's just a convenience method.
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.
See the docs
System.gc()
is equivalent to Runtime.getRuntime().gc()