Sunday, 9 September 2012

Java program to perform garbage collection

import java.util.*;
 
class GarbageCollection
{
   public static void main(String s[]) throws Exception
   {
      Runtime rs =  Runtime.getRuntime();
      System.out.println("Free memory in jvm (Java Virtual Machine) before Garbage Collection        ="+rs.freeMemory());
      rs.gc();
      System.out.println("Free memory in jvm (Java Virtual Machine) after Garbage Collection ="+rs.freeMemory());
   }
}

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...