question: @ SuppressWarnings ( "JavaDoc" ) private static void testUnsafe ( ) throws InterruptedException { X . println ( "Testing unsafe..." ) ; int MAX = 1000000 ; long [ ] addrs = new long [ MAX ] ; System . gc ( ) ; GridTimer t = new GridTimer ( "unsafe" ) ; int mem = 1024 ; for ( int i = 0 ; i < MAX ; i ++ ) { addrs [ i ] = GridUnsafe . allocateMemory ( mem ) ; GridUnsafe . putByte ( addrs [ i ] + RAND . nextInt ( mem ) , ( byte ) RAND . nextInt ( mem ) ) ; v = GridUnsafe . getByte ( addrs [ i ] + RAND . nextInt ( mem ) ) ; } X . println ( "Unsafe [time=" + t . stop ( ) + "ms, v=" + v + ']' ) ; Thread . sleep ( 5000L ) ; for ( long l : addrs ) GridUnsafe . freeMemory ( l ) ; }
target:  Test unsafe vs. new.