code: public static void gc(){
          Object obj = new Object();
          WeakReference ref = new WeakReference<Object>(obj);
          obj = null;
          while(ref.get()!=null)
              System.gc();
      }
docs: This method guarantees that garbage collection is
  done unlike <code>{@link System#gc()}</code>