Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

gc

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!javaRanchers
here is the question about gc
Which of the following regarding garbage collection are true?.(Select two correct answers)
a. An object will be garbage collected immediately after the last reference to the object is removed.
b. If an object ob1 can access an object ob2 that is eligible for garbage collection, then ob1 is also eligible for garbage collection.
c. Circular reference of objects will prevent garbage collection.
d. Once an object has become eligible for garbage collection, it will remain so until it is destroyed.
e. Invoking the finalize() method explicitly on an object will make the object eligible for garbage collection.
f. You can force garbage collection using the System.gc() method.
the answer given is b,f
iam not sure with f.correct me if iam wrong.
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you spend a lot of time around here, you see this similar question come up quite often. The problem with garbage collection is that it is vendor specific, meaning that it's left up to the vendor to implement it accordingly. System.gc() merely suggests to the jvm that it should run the garbage collector, but you can't force anything with it. Some books suggest that you can force it, but it really isn't true. This is a very ambiguos question, and you won't find it on the exam. The kind of gc question you'd find on the exam is when a certain object is eligible for gc. I hope that helps.
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its seems that the book is saying you can kick start the GC when you know you are about to terminate. That way you could make sure all objects are destroyed before termination.
If this is not true, how do you make sure all objects are destoyed after execution stops?
Dan
[This message has been edited by Daniel Dunleavy (edited May 10, 2001).]
 
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic