top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java : Can we force Garbage collector to run at any time ?

+1 vote
375 views
Java : Can we force Garbage collector to run at any time ?
posted Jun 20, 2016 by Karthick.c

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

1 Answer

+1 vote

No, you don't have an option to force garbage collection. The only closest thing we have in Java is System.gc() which intimates or requests the JVM to collect garbage. By which JVM most of the time does GC after the call, sometimes it postpones based on the resource utilization, etc., sometimes it doesn't.

Summary: use System.gc()

answer Jun 20, 2016 by Vinod Kumar K V
...