jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java
changeset 29017 4d33318f0574
parent 28679 42f73a4a323b
child 29018 7f7b6d9e9461
--- a/jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java	Wed Feb 18 11:18:00 2015 +0100
+++ b/jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java	Wed Feb 18 03:16:48 2015 -0800
@@ -55,6 +55,8 @@
 
     // ignoring MaxMetaspaceSize
 
+    static final String desiredMaxHeapSize = "-Xmx128m";
+
     private static Map<String, String> parseJMapOutput(List<String> jmapOutput) {
         Map<String, String> heapConfigMap = new HashMap<String, String>();
         boolean shouldParse = false;
@@ -110,9 +112,23 @@
     public static void main(String[] args) {
         System.out.println("Starting JMapHeapConfigTest");
 
+        boolean mx_found = false;
+        List<String> jvmOptions = Utils.getVmOptions();
+        for (String option : jvmOptions) {
+            if (option.startsWith("-Xmx")) {
+               System.out.println("INFO: maximum heap size set by JTREG as " + option);
+               mx_found = true;
+               break;
+           }
+        }
+
         // Forward vm options to LingeredApp
         ArrayList<String> cmd = new ArrayList();
         cmd.addAll(Utils.getVmOptions());
+        if (!mx_found) {
+            cmd.add(desiredMaxHeapSize);
+            System.out.println("INFO: maximum heap size set explicitly as " + desiredMaxHeapSize);
+        }
         cmd.add("-XX:+PrintFlagsFinal");
 
         TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "-heap");