Author: doogie
Date: Wed Mar 31 06:04:13 2010
New Revision: 929391
URL:
http://svn.apache.org/viewvc?rev=929391&view=revLog:
Helper method to force an OutOfMemory error to occur.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java?rev=929391&r1=929390&r2=929391&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java Wed Mar 31 06:04:13 2010
@@ -27,6 +27,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -42,6 +43,18 @@ public abstract class GenericTestCaseBas
super(name);
}
+ public static void useAllMemory() throws Exception {
+ LinkedList<long[]> dummy = new LinkedList<long[]>();
+ try {
+ do {
+ dummy.add(new long[1048576]);
+ } while (true);
+ } catch (OutOfMemoryError e) {
+ System.gc();
+ Thread.sleep(100);
+ }
+ }
+
public static void assertStaticHelperClass(Class<?> clz) throws Exception {
Constructor<?>[] constructors = clz.getDeclaredConstructors();
assertEquals(clz.getName() + " constructor count", 1, constructors.length);