What is the difference between System.gc()
and Runtime.gc()
?
System.gc():
1: It is a class method(static method).
2: Non-Native method.(Code which doesn't directly interacts with Hardware and System Resources).
3: System.gc(), Internally calls Runtime.getRuntime().gc().
Runtime.gc():
1: Instance method.
2: Native method(A programming language which directly interacts with Hardware and System Resources.).