public static void collectGarbage(long timeout){
  try {
    System.gc();
    Thread.sleep(timeout);
    System.runFinalization();
    Thread.sleep(timeout);
  }
 catch (  InterruptedException ex) {
    ex.printStackTrace();
  }
}

public static void collectGarbage ( long timeout ) { try { System . gc ( ) ; Thread . sleep ( timeout ) ; System . runFinalization ( ) ; Thread . sleep ( timeout ) ; } catch ( InterruptedException ex ) { ex . printStackTrace ( ) ; } }
run a garbage collection .
