wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GC questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GC questions" Watch "GC questions" New topic
Author

GC questions

Ambapali Pal
Ranch Hand

Joined: Dec 17, 2002
Posts: 47
I am confused with GC terms.
1.Garbage Collection can be forced using System.gc() or runtime.gc() . True or False ?
2. Is there any difference in the terms
a)forcing Garbage Collection
b)invoking Garbage Collection explicitly.
3. In no situation it is guaranteed that Garbage Collection will run. Am I right ?
Thanks in advance.
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
Originally posted by Ambapali Pal:
1.Garbage Collection can be forced using System.gc() or runtime.gc() . True or False ?

False.


2. Is there any difference in the terms
a)forcing Garbage Collection
b)invoking Garbage Collection explicitly.

None of them is gurantteed.


3. In no situation it is guaranteed that Garbage Collection will run. Am I right ?

You are right.
Ambapali Pal
Ranch Hand

Joined: Dec 17, 2002
Posts: 47
Thanks Don.
Regarding 1st question there is a line from Khalid/Rasmussen book. "Java provides a facility to invoke the garbage collection explicitly." Ofcourse they are System.gc() and Runtime.gc().
If answer to the 2nd question is that there is no difference between forcing GC and invoking GC explicitly , then how come the above sentense is true???
Any good documents on GC?
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8815
    
    5
Ambapali -
Please read the post dated 12/18 entitled 'one more time G.C. Q & A'. Then write me an email if you have more questions, I have a proposition for you...
-Bert
p.s. You can only make a request to the GC, you can never force it to run, and you can never guarantee that it will run. :roll:


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Ambapali Pal
Ranch Hand

Joined: Dec 17, 2002
Posts: 47
Thanks Bert.
I read 12/18 th post about the GC. That is a very good way of checking the objects which are eligible for GC. I get most of the answer right if I use this method.
Most of the problem I face on GC is the TRUE/FALSE questions about the behavior that is guaranteed by the garbage collection system.
I just dodnot get it right
Right now I donot have any doubt. I will surely have it when I go through the more mock exams. And I will bug you again.
Ambapali
 
Consider Paul's rocket mass heater.
 
subject: GC questions