From c60bdf667b5c6fa767548942f0115547523593b4 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 2 Sep 2014 17:36:08 -0700 Subject: [PATCH] Fix native allocation test. Forgot to update with last CL. Change-Id: Id2f57870b8d4f848cd93012d9da69beee5184be4 --- test/004-NativeAllocations/src/Main.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/004-NativeAllocations/src/Main.java b/test/004-NativeAllocations/src/Main.java index 483c66791..a99fe9208 100644 --- a/test/004-NativeAllocations/src/Main.java +++ b/test/004-NativeAllocations/src/Main.java @@ -15,6 +15,7 @@ */ import java.lang.reflect.*; +import java.lang.Runtime; public class Main { static Object nativeLock = new Object(); @@ -22,7 +23,7 @@ public class Main { static Object runtime; static Method register_native_allocation; static Method register_native_free; - static int maxMem = 64 * 1024 * 1024; + static long maxMem = 0; static class NativeAllocation { private int bytes; @@ -52,8 +53,9 @@ public class Main { runtime = get_runtime.invoke(null); register_native_allocation = vm_runtime.getDeclaredMethod("registerNativeAllocation", Integer.TYPE); register_native_free = vm_runtime.getDeclaredMethod("registerNativeFree", Integer.TYPE); + maxMem = Runtime.getRuntime().maxMemory(); int count = 16; - int size = 512 * 0x400; + int size = (int)(maxMem / 2 / count); int allocation_count = 256; NativeAllocation[] allocations = new NativeAllocation[count]; for (int i = 0; i < allocation_count; ++i) { -- 2.11.0