• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forcing garbage collector

 
vicky malhotra
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way by which we can force garbage collector to act? I mean its true that garbage collector will act on any object for which there is no reference. But the garbage collector works on its own. Can we somehow force it to run?
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.

You can 'recommend' (System.gc()) it to run, but there are not garuntees.
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the other hand, I have found that the garbage collector in j2se will actually finalize and delete all eligible objects in small programs when System.gc() is called. I think this is just a courtesy to students and doesn't change the standard.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic