top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

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

+3 votes
75 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...