goja-core/src/main/java/goja/core/kits/lang/RuntimeKit.java
public static void compactMemory() {
        try {
            final byte[][] unused = new byte[128][];
            for (int i = unused.length; i-- != 0; ) {
                unused[i] = new byte[2000000000];
            }
        } catch (OutOfMemoryError ignore) {
        }
        System.gc();
    }
public static void compactMemory() {
        try {
            final byte[][] unused = new byte[128][];
            for (int i = unused.length; i-- != 0; ) {
                unused[i] = new byte[2000000000];
            }
        } catch (OutOfMemoryError ignore) {
        }
        System.gc();
    }
public static void compactMemory ( ) { try { final byte [ ] [ ] unused = new byte [ 128 ] [ ] ; for ( int i = unused . length ; i -- != 0 ; ) { unused [ i ] = new byte [ 2000000000 ] ; } } catch ( OutOfMemoryError ignore ) { } System . gc ( ) ; }
Compacts memory as much as possible by allocating huge memory block
and then forcing garbage collection.
Compacts memory as much as possible by allocating huge memory block and then forcing garbage collection .