implement Runtime.maxMemory for OpenJDK port

Some apps refuse to run if Runtime.maxMemory returns a value that's
"too small", so our stub implementation returning zero was not
sufficient.  Now we return the actual heap size limit in bytes.
This commit is contained in:
Joel Dice 2012-08-29 18:32:45 -06:00
parent 8c48a44e54
commit 374bdb3726
3 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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,