/*
* Copyright 2009 Google Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A manual test that demonstrates the ability to start a subprocess
* on Linux without getting ENOMEM. Run this test like:
*
* java -Xmx7000m BigFork
*
* providing a -Xmx flag suitable for your operating environment.
* Here's the bad old behavior:
*
* ==> java -Xmx7000m -esa -ea BigFork
* -------
* CommitLimit: 6214700 kB
* Committed_AS: 2484452 kB
* -------
* size=4.6GB
* -------
* CommitLimit: 6214700 kB
* Committed_AS: 7219680 kB
* -------
* Exception in thread "main" java.io.IOException: Cannot run program "/bin/true": java.io.IOException: error=12, Cannot allocate memory
* at java.lang.ProcessBuilder.start(ProcessBuilder.java:1018)
* at BigFork.main(BigFork.java:79)
* Caused by: java.io.IOException: java.io.IOException: error=12, Cannot allocate memory
* at java.lang.UNIXProcess.<init>(UNIXProcess.java:190)
* at java.lang.ProcessImpl.start(ProcessImpl.java:128)
* at java.lang.ProcessBuilder.start(ProcessBuilder.java:1010)
* ... 1 more
*/
public class BigFork {
final int pageSize = 4096;
}
}
BufferedReader r =
new BufferedReader(
new InputStreamReader(
new FileInputStream("/proc/meminfo")));
}
}
}
try {
for (;;) {
}
} catch (OutOfMemoryError e) {
p.waitFor();
}
}
}