Search in sources :

Example 1 with VMOutOfMemoryException

use of com.sun.jdi.VMOutOfMemoryException in project jdk8u_jdk by JetBrains.

the class OomDebugTest method test2.

/*
     * Test case: Array reference as method parameter.
     */
// called via reflection
@SuppressWarnings("unused")
private void test2() throws Exception {
    System.out.println("DEBUG: ------------> Running test2");
    try {
        Field field = targetClass.fieldByName("byteArray");
        ArrayType arrType = (ArrayType) field.type();
        for (int i = 0; i < 15; i++) {
            ArrayReference byteArrayVal = arrType.newInstance(3000000);
            if (byteArrayVal.isCollected()) {
                System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
                continue;
            }
            invoke("testPrimitive", "([B)V", byteArrayVal);
        }
    } catch (VMOutOfMemoryException e) {
        defaultHandleOOMFailure(e);
    }
}
Also used : ArrayType(com.sun.jdi.ArrayType) Field(com.sun.jdi.Field) ArrayReference(com.sun.jdi.ArrayReference) VMOutOfMemoryException(com.sun.jdi.VMOutOfMemoryException)

Aggregations

ArrayReference (com.sun.jdi.ArrayReference)1 ArrayType (com.sun.jdi.ArrayType)1 Field (com.sun.jdi.Field)1 VMOutOfMemoryException (com.sun.jdi.VMOutOfMemoryException)1