22 */ 23 24 /* 25 * @test HeapChangeLogging.java 26 * @bug 8027440 27 * @library /testlibrary 28 * @modules java.base/sun.misc 29 * java.management 30 * @build HeapChangeLogging 31 * @summary Allocate to get a promotion failure and verify that that heap change logging is present. 32 * @run main HeapChangeLogging 33 */ 34 35 import java.util.regex.Matcher; 36 import java.util.regex.Pattern; 37 38 import jdk.test.lib.*; 39 40 public class HeapChangeLogging { 41 public static void main(String[] args) throws Exception { 42 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-XX:+PrintGC", "HeapFiller"); 43 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 44 String stdout = output.getStdout(); 45 System.out.println(stdout); 46 Matcher stdoutMatcher = Pattern.compile("\\[GC .Allocation Failure.*K->.*K\\(.*K\\), .* secs\\]", Pattern.MULTILINE).matcher(stdout); 47 if (!stdoutMatcher.find()) { 48 throw new RuntimeException("No proper GC log line found"); 49 } 50 output.shouldHaveExitValue(0); 51 } 52 } 53 54 class HeapFiller { 55 public static Entry root; 56 private static final int PAYLOAD_SIZE = 1000; 57 58 public static void main(String[] args) { 59 root = new Entry(PAYLOAD_SIZE, null); 60 Entry current = root; 61 try { 62 while (true) { 63 Entry newEntry = new Entry(PAYLOAD_SIZE, current); 64 current = newEntry; 65 } 66 } catch (OutOfMemoryError e) { | 22 */ 23 24 /* 25 * @test HeapChangeLogging.java 26 * @bug 8027440 27 * @library /testlibrary 28 * @modules java.base/sun.misc 29 * java.management 30 * @build HeapChangeLogging 31 * @summary Allocate to get a promotion failure and verify that that heap change logging is present. 32 * @run main HeapChangeLogging 33 */ 34 35 import java.util.regex.Matcher; 36 import java.util.regex.Pattern; 37 38 import jdk.test.lib.*; 39 40 public class HeapChangeLogging { 41 public static void main(String[] args) throws Exception { 42 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-Xlog:gc", "HeapFiller"); 43 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 44 String stdout = output.getStdout(); 45 System.out.println(stdout); 46 Matcher stdoutMatcher = Pattern.compile(".*\\(Allocation Failure\\) [0-9]+[KMG]->[0-9]+[KMG]\\([0-9]+[KMG]\\)", Pattern.MULTILINE).matcher(stdout); 47 if (!stdoutMatcher.find()) { 48 throw new RuntimeException("No proper GC log line found"); 49 } 50 output.shouldHaveExitValue(0); 51 } 52 } 53 54 class HeapFiller { 55 public static Entry root; 56 private static final int PAYLOAD_SIZE = 1000; 57 58 public static void main(String[] args) { 59 root = new Entry(PAYLOAD_SIZE, null); 60 Entry current = root; 61 try { 62 while (true) { 63 Entry newEntry = new Entry(PAYLOAD_SIZE, current); 64 current = newEntry; 65 } 66 } catch (OutOfMemoryError e) { |