changeset 12164:af0b80c1902f

8086117: java/lang/Runtime/exec/LotsOfOutput.java still fails intermittently with Process consumes memory Reviewed-by: chegar
author rriggs
date Wed, 10 Jun 2015 07:52:43 -0400
parents 1c74428aa321
children a44ca223cf2f
files test/java/lang/Runtime/exec/LotsOfOutput.java
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/Runtime/exec/LotsOfOutput.java	Wed Jun 10 12:44:57 2015 +0300
+++ b/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);
 
     }
 }