File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this true in Garbage Collection

 
Sreeraj Harilal
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we use a Garbage collected object again?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you override the finalize method and some how save the object from being garbage collected ( eg: you save the reference to that object ) then the object will not be garbage collected. Once an object is garbage collected it cannot be reached because it has been removed from memory. An object is GC ed only when no reference can reach it , or when an island of isolation occurs.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition :

finalize() method will be called only once in the life time of an object. So even if you override the finalize method and save the object from being garbage collected, finalize() will not be called when it's again eligible for GC.
 
Sreeraj Harilal
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read from somewhere that we can use an object after its finalize method called.
I think finalize is called only before the GC is taken place. right?
Please give me an explanation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic