void dvmSetTargetHeapUtilization(float newTarget);
/*
- * If set is true, sets the new minimum heap size to size; always
- * returns the current (or previous) size. If size is zero,
- * removes the current minimum constraint (if present).
- */
-size_t dvmMinimumHeapSize(size_t size, bool set);
-
-/*
* Initiate garbage collection.
*
* This usually happens automatically, but can also be caused by Runtime.gc().
assert(newTarget > 0.0f && newTarget < 1.0f);
}
-size_t dvmMinimumHeapSize(size_t size, bool set)
-{
- return gDvm.gcHeap->heapSource->minimumSize;
-}
-
/*
* Expands the size of the heap after a collection. At present we
* commit the pages for maximum size of the heap so this routine is
*/
size_t targetUtilization;
- /* Requested minimum heap size, or zero if there is no minimum.
- */
- size_t minimumSize;
-
/* The starting heap size.
*/
size_t startSize;
memset(hs, 0, sizeof(*hs));
hs->targetUtilization = DEFAULT_HEAP_UTILIZATION;
- hs->minimumSize = 0;
hs->startSize = startSize;
hs->absoluteMaxSize = absoluteMaxSize;
hs->idealSize = startSize;
FRACTIONAL_MB(max),
FRACTIONAL_MB(hs->absoluteMaxSize));
max = hs->absoluteMaxSize;
- } else if (max < hs->minimumSize) {
- max = hs->minimumSize;
}
/* Convert max into a size that applies to the active heap.
}
/*
- * If set is true, sets the new minimum heap size to size; always
- * returns the current (or previous) size. If size is negative,
- * removes the current minimum constraint (if present).
- */
-size_t
-dvmMinimumHeapSize(size_t size, bool set)
-{
- HeapSource *hs = gHs;
- size_t oldMinimumSize;
-
- /* gHs caches an entry in gDvm.gcHeap; we need to hold the
- * heap lock if we're going to look at it. We also need the
- * lock for the call to setIdealFootprint().
- */
- dvmLockHeap();
-
- HS_BOILERPLATE();
-
- oldMinimumSize = hs->minimumSize;
-
- if (set) {
- if (size > hs->absoluteMaxSize) {
- size = hs->absoluteMaxSize;
- }
- hs->minimumSize = size;
- if (size > hs->idealSize) {
- /* Force a snap to the minimum value, which we just set
- * and which setIdealFootprint() will take into consideration.
- */
- setIdealFootprint(hs->idealSize);
- }
- /* Otherwise we'll just keep it in mind the next time
- * setIdealFootprint() is called.
- */
- }
-
- dvmUnlockHeap();
-
- return oldMinimumSize;
-}
-
-/*
* Given the size of a live set, returns the ideal heap size given
* the current target utilization and MIN/MAX values.
*
}
/*
- * native long nativeMinimumHeapSize(long size, boolean set)
- *
- * If set is true, sets the new minimum heap size to size; always
- * returns the current (or previous) size. If size is negative or
- * zero, removes the current minimum constraint (if present).
- */
-static void Dalvik_dalvik_system_VMRuntime_nativeMinimumHeapSize(
- const u4* args, JValue* pResult)
-{
- s8 longSize = GET_ARG_LONG(args, 1);
- size_t size;
- bool set = (args[3] != 0);
-
- /* Fit in 32 bits. */
- if (longSize < 0) {
- size = 0;
- } else if (longSize > INT_MAX) {
- size = INT_MAX;
- } else {
- size = (size_t)longSize;
- }
-
- size = dvmMinimumHeapSize(size, set);
-
- RETURN_LONG(size);
-}
-
-/*
* public native void gcSoftReferences()
*
* Does a GC and forces collection of SoftReferences that are
Dalvik_dalvik_system_VMRuntime_getTargetHeapUtilization },
{ "nativeSetTargetHeapUtilization", "(F)V",
Dalvik_dalvik_system_VMRuntime_nativeSetTargetHeapUtilization },
- { "nativeMinimumHeapSize", "(JZ)J",
- Dalvik_dalvik_system_VMRuntime_nativeMinimumHeapSize },
{ "gcSoftReferences", "()V",
Dalvik_dalvik_system_VMRuntime_gcSoftReferences },
{ "runFinalizationSync", "()V",