Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "garbage collection" Watch "garbage collection" New topic
Author

garbage collection

wei liu
Ranch Hand

Joined: Dec 06, 2001
Posts: 56
1. How can you force garbage collection?
[a] Garbage collection cannot be forced
[b] Call System.gc().
[c] Call Runtime.gc().
[d] Set all references to null.
Answer 1
[a] Garbage collection cannot be forced
i think garbage collection canbe forced by calling System.gc()or Runtime.gc(). m I wrong?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
no it cannot be forced you can just tell the gc you would like it to run but nothing is guaranteed...
Try to search the forum for "force garbage collection" you'll find some good discussion about the subject...
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Vikrama Sanjeeva
Ranch Hand

Joined: Sep 02, 2001
Posts: 756
One can request to Sir Garabage Collection could you please run, rather then forcing, Mr.Garabage Collection Run Now!
What do u think Valentin?.
Bye.
Viki.

------------------
Count the flowers of ur garden,NOT the leafs which falls away!


Count the flowers of your garden, NOT the leafs which falls away!
Prepare IBM Exam 340 by joining http://groups.yahoo.com/group/IBM340Exam/
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
not only it is what I think but it is how it is
some useful links:
http://www.javaranch.com/ubb/Forum24/HTML/012281.html
Reference Objects and Garbage Collection
HIH

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
Vikrama Sanjeeva
Ranch Hand

Joined: Sep 02, 2001
Posts: 756
Just have done an overview of the article.It seems me good.
Thanx.
Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
Consider Paul's rocket mass heater.
 
subject: garbage collection