• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Garbage Collection

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which statements were true about GC?
a. You can directly free the memory allocated by an object.
b. You can directly run the garbage collector whenever you want to.
c. The garbage collector informs your object when it is about to be garbage collected.
d. The garbage collector reclaims your object's memory as soon as it becomes a candidate for garbage collection.
e. The garbage collector runs in low memory situations.
f. GC mechanism strictly defined in the JVM.
Please someone tell me the correct answers?
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a. You can directly free the memory allocated by an object.
False. Memory can only be freed by the GC. (It's the boss out there!)
b. You can directly run the garbage collector whenever you want to.
False. You can only request. (by calling System.gc() etc.) When it actually runs depends (on its mood??) ...on it's implementation.
c. The garbage collector informs your object when it is about to be garbage collected.
True. by calling finalize() on that object.
d. The garbage collector reclaims your object's memory as soon as it becomes a candidate for garbage collection.
False. It reclaims the memory when it runs and not when the object becomes available for gc.
e. The garbage collector runs in low memory situations.
False. Not Neccessory. Somebody may write a JVM that runs the GC every 10 mins! It's not specified by Sun.
f. GC mechanism strictly defined in the JVM.
All it says is that the object's finalize() will be called just before it is GCed. Now, I don't know whether it is strictly defined or not. I would guess, No.
HTH,
Paul.
------------------
http://pages.about.com/jqplus
Get Certified, Guaranteed!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic