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.
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.
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.
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]
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:
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:
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:
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