mirror of
https://github.com/corda/corda.git
synced 2025-01-22 04:18:31 +00:00
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:
parent
8c48a44e54
commit
374bdb3726
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user