static void freeMemoryAndFinalize(){
  IOUtils.trace("freeMemoryAndFinalize",null,null);
  Runtime rt=Runtime.getRuntime();
  long mem=rt.freeMemory();
  for (int i=0; i < 16; i++) {
    rt.gc();
    long now=rt.freeMemory();
    rt.runFinalization();
    if (now == mem) {
      break;
    }
    mem=now;
  }
}

static void freeMemoryAndFinalize ( ) { IOUtils . trace ( "freeMemoryAndFinalize" , null , null ) ; Runtime rt = Runtime . getRuntime ( ) ; long mem = rt . freeMemory ( ) ; for ( int i = 0 ; i < 16 ; i ++ ) { rt . gc ( ) ; long now = rt . freeMemory ( ) ; rt . runFinalization ( ) ; if ( now == mem ) { break ; } mem = now ; } }
call the garbage collection and run finalization . this close all files that were not closed , and are no longer referenced .
