• Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt on garbage collection  RSS feed

 
shobhit jain
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How the garbage collection thread is called.
Who calls the garbage collection thread. Is it jvm itself.
Is it called by jvm when ever we start running a program.
And when we say that garbage collection is an automatic process then why do we implement in our code time to time.It should not make any sense if garbage collection runs on its own and if the garbage collection can not be forced.
Kindly explain.
 
Brij Garg
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is the JVM which is responsible to run garbage collection.

System.gc() is just a sort of request to run garbage collection.Nothing else then it. JVM may run it or not.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by shobhit jain:
. . . why do we implement System.gc() in our code . . .
It is not usual to implement System.gc(). Only very rarely is that call at all useful.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!