equal
deleted
inserted
replaced
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @summary Verifies behaviour of Unsafe.allocateMemory |
26 * @summary Verifies behaviour of Unsafe.allocateMemory |
27 * @library /testlibrary |
27 * @library /testlibrary |
28 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=20m AllocateMemory |
28 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m AllocateMemory |
29 */ |
29 */ |
30 |
30 |
31 import com.oracle.java.testlibrary.*; |
31 import com.oracle.java.testlibrary.*; |
32 import sun.misc.Unsafe; |
32 import sun.misc.Unsafe; |
33 import static com.oracle.java.testlibrary.Asserts.*; |
33 import static com.oracle.java.testlibrary.Asserts.*; |
54 } |
54 } |
55 |
55 |
56 // allocateMemory() should throw an OutOfMemoryError when the underlying malloc fails, |
56 // allocateMemory() should throw an OutOfMemoryError when the underlying malloc fails, |
57 // we test this by limiting the malloc using -XX:MallocMaxTestWords |
57 // we test this by limiting the malloc using -XX:MallocMaxTestWords |
58 try { |
58 try { |
59 address = unsafe.allocateMemory(20 * 1024 * 1024 * 8); |
59 address = unsafe.allocateMemory(100 * 1024 * 1024 * 8); |
60 } catch (OutOfMemoryError e) { |
60 } catch (OutOfMemoryError e) { |
61 // Expected |
61 // Expected |
62 return; |
62 return; |
63 } |
63 } |
64 throw new RuntimeException("Did not get expected OutOfMemoryError"); |
64 throw new RuntimeException("Did not get expected OutOfMemoryError"); |