Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 377c06d1 authored by Wei Wang's avatar Wei Wang Committed by Linux Build Service Account
Browse files

GC triggering performance optimizations

Copy the correct starting heap size at process init.
Interfaces to set GC/managed heap parameters.

Change-Id: Idc02ef35c6045c129addcac17628eefffe958805
(cherry picked from commit 71c3f30fc9ad6ecaf534a02b6e795d86628d923b)
(cherry picked from commit a93fe7200b5df163e13e11059555ddcbdcbbf808)
(cherry picked from commit cc68d4a09b89aa71e5dd08ee6a220200f4e084e9)
parent 3a93c59e
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -117,6 +117,9 @@ import libcore.io.EventLogger;
import libcore.io.IoUtils;

import dalvik.system.CloseGuard;
import dalvik.system.VMRuntime;
import android.os.SystemProperties;
import java.lang.*;

final class RemoteServiceException extends AndroidRuntimeException {
    public RemoteServiceException(String msg) {
@@ -4085,6 +4088,36 @@ public final class ActivityThread {

        // send up app name; do this *before* waiting for debugger
        Process.setArgV0(data.processName);

        String str  = SystemProperties.get("dalvik.vm.heaputilization", "" );
        if( !str.equals("") ){
            float heapUtil = Float.valueOf(str.trim()).floatValue();
            VMRuntime.getRuntime().setTargetHeapUtilization(heapUtil);
            Log.d(TAG, "setTargetHeapUtilization:" + str );
        }
        int heapMinFree  = SystemProperties.getInt("dalvik.vm.heapMinFree", 0 );
        if( heapMinFree > 0 ){
            VMRuntime.getRuntime().setTargetHeapMinFree(heapMinFree);
            Log.d(TAG, "setTargetHeapMinFree:" + heapMinFree );
        }
        int heapConcurrentStart  = SystemProperties.getInt("dalvik.vm.heapconcurrentstart", 0 );
        if( heapConcurrentStart > 0 ){
            VMRuntime.getRuntime().setTargetHeapConcurrentStart(heapConcurrentStart);
            Log.d(TAG, "setTargetHeapConcurrentStart:" + heapConcurrentStart );
        }

        ////
        ////If want to set application specific GC paramters, can use
        ////the following check
        ////
        //if( data.processName.equals("com.android.gallery3d")) {
        //    VMRuntime.getRuntime().setTargetHeapUtilization(0.25f);
        //    VMRuntime.getRuntime().setTargetHeapMinFree(12*1024*1024);
        //    VMRuntime.getRuntime().setTargetHeapConcurrentStart(4*1024*1024);
        //}



        android.ddm.DdmHandleAppName.setAppName(data.processName,
                                                UserHandle.myUserId());