test/java/lang/Runtime/exec/LotsOfOutput.java
Print this page
*** 24,45 ****
/**
* @test
* @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.");
--- 24,44 ----
/**
* @test
* @bug 4369826
* @summary Process with lots of output should not crash VM
* @author kladko
+ * @run main/othervm LotsOfOutput
*/
public class LotsOfOutput {
! public static void main(String[] args) throws Exception {
! if (System.getProperty("os.name").startsWith("Windows")) {
! System.err.println("Not for Windows");
return;
! }
! 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.");