test/java/lang/Runtime/exec/LotsOfOutput.java

Print this page

        

*** 26,45 **** * @bug 4369826 * @summary Process with lots of output should not crash VM * @author kladko */ - import java.io.File; - public class LotsOfOutput { - static final String CAT = "/usr/bin/cat"; ! public static void main(String[] args) throws Exception{ ! if (File.separatorChar == '\\' || // Windows ! !new File(CAT).exists()) // no cat return; ! Process p = Runtime.getRuntime().exec(CAT + " /dev/zero"); long initMemory = Runtime.getRuntime().totalMemory(); for (int i=1; i< 10; i++) { Thread.sleep(100); if (Runtime.getRuntime().totalMemory() > initMemory + 1000000) throw new Exception("Process consumes memory."); --- 26,45 ---- * @bug 4369826 * @summary Process with lots of output should not crash VM * @author kladko */ public class LotsOfOutput { ! public static void main(String[] args) throws Exception { ! if (! UnixCommands.isUnix) { ! System.out.println("For UNIX only"); return; ! } ! UnixCommands.ensureCommandsAvailable("cat"); ! ! Process p = Runtime.getRuntime().exec(UnixCommands.cat() + " /dev/zero"); long initMemory = Runtime.getRuntime().totalMemory(); for (int i=1; i< 10; i++) { Thread.sleep(100); if (Runtime.getRuntime().totalMemory() > initMemory + 1000000) throw new Exception("Process consumes memory.");