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

Commit 81568c5c authored by Wei Wang's avatar Wei Wang Committed by Ricardo Cerqueira
Browse files

GC triggering performance optimizations

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

Change-Id: I0154d1523c3cfdb1214ed0315193cbb24704351f
parent 6356a2e2
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -124,6 +124,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) {
@@ -4116,6 +4119,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());