summaryrefslogtreecommitdiffstats
path: root/test/104-growth-limit
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-04-14 11:33:53 -0700
committerMathieu Chartier <mathieuc@google.com>2015-04-14 11:41:17 -0700
commit44fe8b32265e81a5539aa6730ba8ded270913d3a (patch)
tree1f170380e5bdf9c49de6b60127b6efad97074dc4 /test/104-growth-limit
parent2ff3c2cd515963ca8ba493c22a24f9e0df4f1bdd (diff)
downloadart-44fe8b32265e81a5539aa6730ba8ded270913d3a.zip
art-44fe8b32265e81a5539aa6730ba8ded270913d3a.tar.gz
art-44fe8b32265e81a5539aa6730ba8ded270913d3a.tar.bz2
Fix test 104 for --relocate --no-patchoat
Failure caused by keeping an array live in a vreg, this caused getDeclaredMethod to throw OOME. Change-Id: Id2aa976af0978cdd7354fb94b3becfcc85e19ca2
Diffstat (limited to 'test/104-growth-limit')
-rw-r--r--test/104-growth-limit/src/Main.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/104-growth-limit/src/Main.java b/test/104-growth-limit/src/Main.java
index 55469db..d666377 100644
--- a/test/104-growth-limit/src/Main.java
+++ b/test/104-growth-limit/src/Main.java
@@ -21,8 +21,14 @@ import java.util.List;
public class Main {
public static void main(String[] args) throws Exception {
-
int alloc1 = 1;
+ // Setup reflection stuff before allocating to prevent OOME caused by allocations from
+ // Class.forName or getDeclaredMethod.
+ // Reflective equivalent of: dalvik.system.VMRuntime.getRuntime().clearGrowthLimit();
+ final Class<?> vm_runtime = Class.forName("dalvik.system.VMRuntime");
+ final Method get_runtime = vm_runtime.getDeclaredMethod("getRuntime");
+ final Object runtime = get_runtime.invoke(null);
+ final Method clear_growth_limit = vm_runtime.getDeclaredMethod("clearGrowthLimit");
try {
List<byte[]> l = new ArrayList<byte[]>();
while (true) {
@@ -33,13 +39,7 @@ public class Main {
} catch (OutOfMemoryError e) {
}
// Expand the heap to the maximum size.
- // Reflective equivalent of: dalvik.system.VMRuntime.getRuntime().clearGrowthLimit();
- Class<?> vm_runtime = Class.forName("dalvik.system.VMRuntime");
- Method get_runtime = vm_runtime.getDeclaredMethod("getRuntime");
- Object runtime = get_runtime.invoke(null);
- Method clear_growth_limit = vm_runtime.getDeclaredMethod("clearGrowthLimit");
clear_growth_limit.invoke(runtime);
-
int alloc2 = 1;
try {
List<byte[]> l = new ArrayList<byte[]>();