Why we can not force Garbage Collection?
Answers were Sorted based on User's Feedback
Answer / ramesh9396962999
we can request it by calling System.gc() or Runtime.gc() but
there is no guarante that gc will run immidiately.....
Is This Answer Correct ? | 19 Yes | 1 No |
Answer / pradeep panwar
Hi All....
yea thats true that we can't force for Garbage Collection.
We can send a request by system.gc(); at any time but its
not sure that garbage collection takes place at that time.
It depends on memory. So we cant forcr fot GC either
sending the explicit request.
can catch me on +91-9899954354
Is This Answer Correct ? | 13 Yes | 1 No |
Answer / 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 |
Answer / rohit
when jvm find that the object of that class is not used for
long time ,if that situation occurs then jmv jmv
automatically calls that garbage collector
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / vineet verma[birlasoft]
garbage collection is a independent thread in memory.JVM
set the priorty of this thread.system.gc() just request the
JVM to run garbage collection.its up to JVM wether to set
priorty and when..
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / neeraj_passion2001
who says can not run garbage collector forcefuly?
we can as System.gc();
Is This Answer Correct ? | 4 Yes | 15 No |
Can we write class inside a class in java?
what is the use of clone() in real time scenario?
What do you mean by boolean?
Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me
When can you say a graph to be a tree?
There are 2 different ways to create an object. a)By using keyword "new" b)By using Class.forName ("className").newInstance(); What is the difference between these 2 methods.
What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?
How we can execute any code even before main method?
What are the features of junit?
Is oracle charging for java?
How do you sort a set in java?
How many bytes is a string java?