• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection

 
Sharada Kumaran
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read in some places that Garbage Collection in java cannot be forced. If this is true, what does System.gc() do?
What does Runtime.gc() do?
 
Jonathan Jones
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.gc() or Runtime.gc() simply make a tentative call to run the garbage collector. They do not force at all the garbage collector to be run. Thus the garbage collector may or may not run, but you can never be sure
Regards
Jonathan
 
Samith Nambiar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
a small correction ... that would be Runtime.getRuntime().gc()
this is because gc() is not a static method
Samith.P.Nambiar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic