private static void garbageCollect(){
  try {
    System.gc();
    Thread.sleep(200);
    System.runFinalization();
    Thread.sleep(200);
    System.gc();
    Thread.sleep(200);
    System.runFinalization();
    Thread.sleep(200);
  }
 catch (  InterruptedException ex) {
    ex.printStackTrace();
  }
}

private static void garbageCollect ( ) { try { System . gc ( ) ; Thread . sleep ( 200 ) ; System . runFinalization ( ) ; Thread . sleep ( 200 ) ; System . gc ( ) ; Thread . sleep ( 200 ) ; System . runFinalization ( ) ; Thread . sleep ( 200 ) ; } catch ( InterruptedException ex ) { ex . printStackTrace ( ) ; } }
makes sure all garbage is cleared from the memory .
