• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

garbage collection!

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
which of these options are true for the following question?(from Boone's Mock-exam).
Question 65: Which statements about garbage collection are true?
Select all valid answers.
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 an object�s memory as soon as it becomes a candidate for garbage collection.
e) The garbage collector runs in low-memory situations.
 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the answer is b. You can call the garbage collector by invoking system.gc() method.But there is no gaurantee that the objeects will be collected immediately because garbage collection is usually performed in low memory conditions

Originally posted by ashok khetan:
hi,
which of these options are true for the following question?(from Boone's Mock-exam).
Question 65: Which statements about garbage collection are true?
Select all valid answers.
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 an object�s memory as soon as it becomes a candidate for garbage collection.
e) The garbage collector runs in low-memory situations.


 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is c and e.
rajani
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Rajani.Since if you look at option b more carefully,it will be clear that the option says about running GC which is no gurantee at all.Of course, you can call System.gc() but again, as Roopa mentions,it is a request rather than running it.
THANKS.
 
Roopa Bagur
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really don't understand option c. Could you please explain it

Originally posted by Bindesh Vijayan:
I agree with Rajani.Since if you look at option b more carefully,it will be clear that the option says about running GC which is no gurantee at all.Of course, you can call System.gc() but again, as Roopa mentions,it is a [b]request rather than running it.
THANKS.[/B]


 
Bindesh Vijayan
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roopa,
Actually I think, what happens is when GC is to be done it calls finalize() on that particular object and this way it informs the object of being GC'd. You can view this phenomenon on the following code:

THANKS
 
Roopa Bagur
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bindesh. Good answer

Originally posted by Bindesh Vijayan:
[B]Roopa,
Actually I think, what happens is when GC is to be done it calls finalize() on that particular object and this way it informs the object of being GC'd. You can view this phenomenon on the following code:

THANKS[/B]


 
Roopa Bagur
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bindesh. Good answer

Originally posted by Bindesh Vijayan:
[B]Roopa,
Actually I think, what happens is when GC is to be done it calls finalize() on that particular object and this way it informs the object of being GC'd. You can view this phenomenon on the following code:

THANKS[/B]


 
Bindesh Vijayan
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roopa,
I would like to add here that, although the finalize is being called by Gc it's not Garbage Collection, still because it only does cleanup.And only when next time the finalize is callled the GC does the actual work on the object.This is what I studied in Thinking in Java, Bruce Eckel
Thanks.
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic