Fix native allocation test.
Forgot to update with last CL.
(cherry picked from commit c60bdf667b5c6fa767548942f0115547523593b4)
Change-Id: I41ad168a5906ca07938bdd212a55f0e995ee5df7
diff --git a/test/004-NativeAllocations/src/Main.java b/test/004-NativeAllocations/src/Main.java
index 483c667..a99fe92 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 @@
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 @@
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) {