• Post Reply Bookmark Topic Watch Topic
  • New Topic

System.gc()

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reading about the garbage collection in Java text books teaches you that you can request the gc to be run, not that it will run, i.e that you can never be sure that it will run. For instance, Exam Cram, Bill Brogden, p 154 " The programmer can suggest to the JVM ... to run garbage collection ... but there is no guarantee that the JVM will do it". However, in Sun's tutorial (Essential Java Classes - Accessing System Resources, http://java.sun.com/docs/books/tutorial/essential/system/index.html)it says "In Java, you don't have to free an object when you're done with it-the garbage collector runs periodically in the background and cleans up unreferenced objects. Or you can force the garbage collector to run using System's gc method.". Force beeing the keyword here, the correct beeing ?
 
red lee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should say *try* to force garbace collection. Runtime.gc() and System.gc() only suggest that the JVM recycles memory.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!