Why we can not force Garbage Collection?

Answer Posted / mohit

Hi Friends.. System.gc()does not forcefully to gc.it request
only.it has only 10% chance to run gc.but if u use
thread.sleep(1000);it has chance 50% to run gc.but if u use
for(i=1;i<=1000;i++)
{
System.gc();
}
so it has 99% chance to run gc.because gc release the memory
only when heap is full otherwise JVM is very lasy.....

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where we write javascript code in html page?

553


How many types of literals are there in JAVA?

588


How do you sort data in java?

514


Say any two properties in beans?

628


What is string [] java?

522






What are strings in physics?

537


Can a class have 2 constructors?

490


What is a local class in java?

575


What is java reflection?

529


What are the methods to rectify ambiguities in the interfaces in JAVA?

580


What is singleton service?

498


What is data structure in java?

525


Is sizeof a preprocessor?

536


What is a finally block?

550


What does pointer mean?

539