GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes question on GC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "question on GC" Watch "question on GC" New topic
Author

question on GC

sanjana narayanan
Ranch Hand

Joined: Nov 25, 2003
Posts: 142
can someone tell me the difference between System.gc and Runtime.gc().?
-Sanjana
Derek Baker
Ranch Hand

Joined: May 23, 2003
Posts: 46
From the API docs:

The call System.gc() is effectively equivalent to the call:
Runtime.getRuntime().gc()

And:
The method System.gc() is the conventional and convenient means of invoking this method (Runtime.getRuntime().gc()).
Sumitro Palit
Ranch Hand

Joined: Dec 13, 2003
Posts: 37
Sanjana,
There is no difference.
System.gc calls Runtime.gc
Check your installed jdk's source code.
You'll find System.java has the gc method as follows:
public static void gc() {
Runtime.getRuntime().gc();
}
-ortimus
"Simplicity is virtue"
sanjana narayanan
Ranch Hand

Joined: Nov 25, 2003
Posts: 142
Thanks for the reply..
-sanjana
 
GeeCON Prague 2014
 
subject: question on GC