diff --git a/classpath/java/lang/Runtime.java b/classpath/java/lang/Runtime.java index 6d1faf812..e73d74b35 100644 --- a/classpath/java/lang/Runtime.java +++ b/classpath/java/lang/Runtime.java @@ -129,6 +129,8 @@ private static native void exec(String[] command, long[] process) public native long freeMemory(); public native long totalMemory(); + + public native long maxMemory(); private static class MyProcess extends Process { private long pid; diff --git a/src/builtin.cpp b/src/builtin.cpp index 46b82f474..4369ec62d 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -371,6 +371,12 @@ extern "C" AVIAN_EXPORT int64_t JNICALL return t->m->heap->limit(); } +extern "C" AVIAN_EXPORT int64_t JNICALL + Avian_java_lang_Runtime_maxMemory(Thread* t, object, uintptr_t*) +{ + return t->m->heap->limit(); +} + extern "C" AVIAN_EXPORT int64_t JNICALL Avian_avian_avianvmresource_Handler_00024ResourceInputStream_getContentLength( Thread* t, diff --git a/test/Misc.java b/test/Misc.java index ab69d7490..19195277a 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -360,6 +360,7 @@ public static void main(String[] args) throws Exception { // just test that it's there; don't care what it returns: Runtime.getRuntime().totalMemory(); + Runtime.getRuntime().maxMemory(); } protected class Protected { }