8086117: java/lang/Runtime/exec/LotsOfOutput.java still fails intermittently with Process consumes memory
authorrriggs
Wed, 10 Jun 2015 07:52:43 -0400
changeset 31083 235eb8c336a9
parent 31082 564165d013bb
child 31084 0acb07ceb0bc
8086117: java/lang/Runtime/exec/LotsOfOutput.java still fails intermittently with Process consumes memory Reviewed-by: chegar
jdk/test/java/lang/Runtime/exec/LotsOfOutput.java
--- a/jdk/test/java/lang/Runtime/exec/LotsOfOutput.java	Wed Jun 10 12:44:57 2015 +0300
+++ b/jdk/test/java/lang/Runtime/exec/LotsOfOutput.java	Wed Jun 10 07:52:43 2015 -0400
@@ -48,20 +48,21 @@
         UnixCommands.ensureCommandsAvailable("cat");
 
         Process p = runtime.exec(UnixCommands.cat() + " /dev/zero");
-        long initMemory = usedMemory();
-        boolean growing = false;
+        long prev = usedMemory();
+        int growing = 0;
         for (int i = 1; i < 10; i++) {
             Thread.sleep(100);
             long used = usedMemory();
-            if (used != initMemory) {
-                System.out.printf("consuming memory: i: %d, initial: %d, used: %d, delta: %d%n",
-                        i, initMemory, used, used - initMemory);
+            if (used != prev) {
+                System.out.printf("consuming memory: i: %d, prev: %d, used: %d, delta: %d%n",
+                        i, prev, used, used - prev);
             }
-            if (used > initMemory + THRESHOLD)
-                growing = true;
+            if (used > prev + THRESHOLD)
+                growing += 1;
+            prev = used;
         }
-        if (growing)
-            throw new Exception("Process consumes memory.");
+        if (growing > 2)
+            throw new Exception("Process consumes memory: growing " + growing);
 
     }
 }