Java examples for Java Virtual Machine:Utility
How to run the garbage collector by using gc method of System class.
public class Main { public static void main(String[] args) { System.out.println("Suggesting VM to run garbage collector"); System.gc();// w w w . ja va 2 s.c o m System.out.println("Suggested VM to garbage collect objects"); } }