summaryrefslogtreecommitdiffstats
path: root/vm/native/java_lang_Runtime.c
diff options
context:
space:
mode:
authorCarl Shapiro <cshapiro@google.com>2011-01-18 17:59:30 -0800
committerCarl Shapiro <cshapiro@google.com>2011-01-18 17:59:30 -0800
commitdf9f08b877ecfd8ebadea822bb9e066ee7d30433 (patch)
tree2ace664586d3f29a5183e6f71e2f8138c69cb83a /vm/native/java_lang_Runtime.c
parent241cec80a79551730122fb9dbc92a3527392b1de (diff)
downloadandroid_dalvik-df9f08b877ecfd8ebadea822bb9e066ee7d30433.tar.gz
android_dalvik-df9f08b877ecfd8ebadea822bb9e066ee7d30433.tar.bz2
android_dalvik-df9f08b877ecfd8ebadea822bb9e066ee7d30433.zip
Implement growth limits to support multiple heap configurations.
When a growth limit is in effect, allocations will be limited to number of bytes specified by the growth limit instead of the maximum heap size. Growth limits are specified on the command line with the new parameter -XX:HeapGrowthLimit. A growth limit can be removed at runtime by calling the new clearGrowthLimit method. This is a work around until we can adjust the maximum heap size at runtime. Change-Id: Ic01e32823b5ca8cf29c0948fb6cd2df10967c1fb
Diffstat (limited to 'vm/native/java_lang_Runtime.c')
-rw-r--r--vm/native/java_lang_Runtime.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/vm/native/java_lang_Runtime.c b/vm/native/java_lang_Runtime.c
index d28ff8466..90df25902 100644
--- a/vm/native/java_lang_Runtime.c
+++ b/vm/native/java_lang_Runtime.c
@@ -138,38 +138,37 @@ static void Dalvik_java_lang_Runtime_availableProcessors(const u4* args,
RETURN_INT((int)result);
}
/*
- * public void maxMemory()
+ * public long maxMemory()
*
* Returns GC heap max memory in bytes.
*/
static void Dalvik_java_lang_Runtime_maxMemory(const u4* args, JValue* pResult)
{
- unsigned int result = gDvm.heapSizeMax;
- RETURN_LONG(result);
+ RETURN_LONG(dvmGetHeapDebugInfo(kVirtualHeapMaximumSize));
}
/*
- * public void totalMemory()
+ * public long totalMemory()
*
* Returns GC heap total memory in bytes.
*/
static void Dalvik_java_lang_Runtime_totalMemory(const u4* args,
JValue* pResult)
{
- int result = dvmGetHeapDebugInfo(kVirtualHeapSize);
- RETURN_LONG(result);
+ RETURN_LONG(dvmGetHeapDebugInfo(kVirtualHeapSize));
}
/*
- * public void freeMemory()
+ * public long freeMemory()
*
* Returns GC heap free memory in bytes.
*/
static void Dalvik_java_lang_Runtime_freeMemory(const u4* args,
JValue* pResult)
{
- int result = dvmGetHeapDebugInfo(kVirtualHeapSize)
- - dvmGetHeapDebugInfo(kVirtualHeapAllocated);
+ size_t size = dvmGetHeapDebugInfo(kVirtualHeapSize);
+ size_t allocated = dvmGetHeapDebugInfo(kVirtualHeapAllocated);
+ long long result = size - allocated;
if (result < 0) {
result = 0;
}