top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can we force Garbage Collection in Java, if yes then how?

+3 votes
550 views
Can we force Garbage Collection in Java, if yes then how?
posted Oct 22, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
 
Best answer

I agree with Salil's view. However there is lot changes in JVM spec w.r.t GC. and it depends on GC implementation however JSR says that call to GC must be a suggestion to GC daemon thread and not a immediate higher thread priority to execute.

answer May 4, 2015 by Priya Ranjan Kumar
0 votes

You can not force garbage collection. Only you can call System.gc() which simply is a hint to the garbage collector that you want it to do a garbage collection.

There is no way to force and immediate collection though as garbage collector is non-deterministic.

answer Oct 22, 2014 by Salil Agrawal
...