public static void main(String[] args) { // Some code here
// Invoke the Garbage Collector here.
System.gc(); // Some more code here
// Invoke the Garbage Collector again.
Runtime.getRuntime().gc(); }
In the above code, both calls seem to invoke the Garbage Collector. So what is the difference between System.gc() and Runtime.getRuntime().gc()?
Looking at the API documentation for System.gc() it invokes Runtime.getRuntime().gc()which means they are the same and System.gc() is only a convenience method.
No comments:
Post a Comment