aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes System.gc() problem 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 "System.gc() problem" Watch "System.gc() problem" New topic
Author

System.gc() problem

Anuji Philip
Ranch Hand

Joined: Feb 25, 2002
Posts: 46
From Boone Exam:
Which statement about g.c are true?Select all valid answers?
a>you can directly free the memory allocated by an object
b>you can directly run the g.c when I want
c>g.c informs your object when it is about to be garbage collected.
d>g.c reclaims an object's memory as soon as it becomes a candidate for garbage collection.
e>g.c runs in low memory situations.
Ans: b,c
But my answer was c,e.
If we use System.gc() ,is it g.c thread forced to run immediately but no garbage collection takes place until it is eligible by some random
manipulation of memory management?My idea was g.c thread will run when eligible only eve if we use System.gc().
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
Calling System.gc() does not guarantee that a GC thread will be started, so I disagree with b.
Bill
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
And e is wrong too, since there is no guarantee that this will be the case. There is no specification as how to implement the GC. Running the GC in low-memory situation can be implemented by one JVM provider but another provider may have another heuristic.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System.gc() problem
 
Similar Threads
can agrbage collection be forced???
a question about GC
about garbage collectiion
Boone Exam3 question
garbage collection