programming-examples/java/Basics/Java program to perform garbage collection.java
2019-11-18 14:44:36 +01:00

12 lines
378 B
Java

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