Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GC

 
sean cee
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
are following statements about garbage collection true?
a) GC informs your object when it is about to be garbage collected.
b) GC runs in low-memory situations.
Not sure about a)
I thought b) is false .. cos GC is vendor dependent.
Any idea?
Thanks in advance..
 
Vaneet Bhutani
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that a) is false, too. Logically, it does not seem to make cany sense to inform the object that is to be garbage collected that you are gonna' be gc'd.
Could the ranch-experts nod yes/no!
 
lakshmi nair
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a is true. And that is why finalize() is run before an object is garbage collected.
And i think b is false, since you cannot guarantee that gc will run, even at low memory situations.
Lakshmi
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic