This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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. Answer Given - b,c,e I think,B is again not correctly worded...or is it..I hope,in real exam , wordings are more clear.. Comments-- Thanx
Hi, I think one can forcefully run the garbage collector by calling System.gc() method.In this way you force garbage collector to be called to reclaim the memory.If a forceful call is not done then the gc is called only when the JVM finds it is running low in memory,otherwise it will not call garbage collector and the memory will be reclaimed by the Operating System when the program ends.Although calling garbage collector is a waste of time.So I think b and e both are right and since I have no idea of any information being given to object by the gc, I'll stay quite. If you want to see an example where you call gc and see the process of gc,then here is the code:-
One thing that I must add to the behavior of the program is that Iam not assigning it to any variable of A (see line#1) ,thus the objects created using new remains unreferenced thereby creating work for garbage collector.Had it been assigned to any object reference gc would'nt have work.I found it out lately. This is what my understanding says,I may be wrong, so please correct me. THANKS [This message has been edited by Bindesh Vijayan (edited August 29, 2001).]
my understanding is that gc is a thread and one can not be sure when it is going to run even after the System.gc(); method. correct me if i'm wrong. thanx. Jennifer
Joined: Oct 18, 2000
Hi, I think ,c and e, are correct options. Regarding b,Yes, we can call System.gc() but we can NOT guarantee that Garbage Collector will run..So the option.."You can run directlt Garbage Collector" Whenever you can" shd be false. Regarding C, Objects gets notified before actual Garbage Collection...remember finalize() is called.. Hope it is correct... Thanx
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com