diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index f4de3f9fca..299441a9b7 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -3116,7 +3116,7 @@ EXPORT(JVM_FreeMemory)() extern "C" JNIEXPORT jlong JNICALL EXPORT(JVM_MaxMemory)() { - return 0; + return local::globalMachine->heap->limit(); } extern "C" JNIEXPORT jint JNICALL diff --git a/src/heap.cpp b/src/heap.cpp index 0bc37862fd..b46faeda01 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -1867,6 +1867,10 @@ class MyHeap: public Heap { c.immortalHeapEnd = start + sizeInWords; } + virtual unsigned limit() { + return c.limit; + } + virtual bool limitExceeded() { return c.count > c.limit; } diff --git a/src/heap.h b/src/heap.h index c3f1f8b4c8..0ee4699914 100644 --- a/src/heap.h +++ b/src/heap.h @@ -59,6 +59,7 @@ class Heap: public Allocator { virtual void setClient(Client* client) = 0; virtual void setImmortalHeap(uintptr_t* start, unsigned sizeInWords) = 0; + virtual unsigned limit() = 0; virtual bool limitExceeded() = 0; virtual void collect(CollectionType type, unsigned footprint) = 0; virtual void* allocateFixed(Allocator* allocator, unsigned sizeInWords,