Suggest JVM to Run Garbage Collector - Java Java Virtual Machine

Java examples for Java Virtual Machine:Utility

Description

Suggest JVM to Run Garbage Collector

Demo Code


public class Main {
 
        public static void main(String args[])
        {/*from  ww  w .j a v  a2  s . c  om*/
                Runtime runtime = Runtime.getRuntime();
                runtime.gc();
                System.out.println("JVM has made best effort to garbage collect!");
        }
       
}

Result


Related Tutorials