Merge pull request #110 from dscho/memory

Implement Runtime#{free,total}Memory()
This commit is contained in:
Joshua Warner 2013-12-04 13:43:45 -08:00
commit bb18637f13
3 changed files with 9 additions and 6 deletions

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 remaining() = 0;
virtual unsigned limit() = 0;
virtual bool limitExceeded(int pendingAllocation = 0) = 0;
virtual void collect(CollectionType type, unsigned footprint,

View File

@ -593,18 +593,16 @@ Avian_java_lang_Runtime_gc
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Runtime_freeMemory
(Thread*, object, uintptr_t*)
(Thread* t, object, uintptr_t*)
{
// todo
return 0;
return t->m->heap->remaining();
}
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Runtime_totalMemory
(Thread*, object, uintptr_t*)
(Thread* t, object, uintptr_t*)
{
// todo
return 0;
return t->m->heap->limit();
}
extern "C" AVIAN_EXPORT void JNICALL

View File

@ -1888,6 +1888,10 @@ class MyHeap: public Heap {
c.immortalHeapEnd = start + sizeInWords;
}
virtual unsigned remaining() {
return c.limit - c.count;
}
virtual unsigned limit() {
return c.limit;
}