question: public static void forceGC ( ) { WeakReference < Object > dumbReference = new WeakReference < > ( new Object ( ) ) ; while ( dumbReference . get ( ) != null ) { System . gc ( ) ; try { Thread . sleep ( 500 ) ; } catch ( InterruptedException e ) { } } }
target:  Some testcases are time sensitive, and we need to make sure a GC would happen before certain scenarios