• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question on GC

 
sanjana narayanan
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can someone tell me the difference between System.gc and Runtime.gc().?
-Sanjana
 
Derek Baker
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply..
-sanjana
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic