< prev index next >

test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java

Print this page
@  rev 57446 : Review changes
|
~

*** 63,84 **** --- 63,92 ---- private static void testMemoryFailCount() { long count = Metrics.systemMetrics().getMemoryFailCount(); // Allocate 512M of data byte[][] bytes = new byte[64][]; + boolean atLeastOneAllocationWorked = false; for (int i = 0; i < 64; i++) { try { bytes[i] = new byte[8 * 1024 * 1024]; + atLeastOneAllocationWorked = true; // Break out as soon as we see an increase in failcount // to avoid getting killed by the OOM killer. if (Metrics.systemMetrics().getMemoryFailCount() > count) { break; } } catch (Error e) { // OOM error break; } } + if (!atLeastOneAllocationWorked) { + System.out.println("Allocation failed immediately. Ignoring test!"); + return; + } + // Be sure bytes allocations don't get optimized out + System.out.println("DEBUG: Bytes allocation length 1: " + bytes[0].length); if (Metrics.systemMetrics().getMemoryFailCount() <= count) { throw new RuntimeException("Memory fail count : new : [" + Metrics.systemMetrics().getMemoryFailCount() + "]" + ", old : [" + count + "]"); }
< prev index next >