1. 程式人生 > >Android Dalvik VM GC options 命令控制引數

Android Dalvik VM GC options 命令控制引數

} else if (strncmp(argv[i], "-Xgc:", 5) == 0) {
    //In VM thread, there is a register map for marking each stack item's status whether it is an object or internal value. And In GC step, only object item will be marked. If this value is OFF, all stack will be marked even if the item is only an integer.
    if (strcmp(argv[i] + 5, "precise") == 0)
        gDvm.preciseGc = true;
    else if (strcmp(argv[i] + 5, "noprecise") == 0)
        gDvm.preciseGc = false;
    //Only for GC verify check
    else if (strcmp(argv[i] + 5, "preverify") == 0)
        gDvm.preVerify = true;
    else if (strcmp(argv[i] + 5, "nopreverify") == 0)
        gDvm.preVerify = false;
    else if (strcmp(argv[i] + 5, "postverify") == 0)
        gDvm.postVerify = true;
    else if (strcmp(argv[i] + 5, "nopostverify") == 0)
        gDvm.postVerify = false;
    //Open/Close Dalvik vm GC markseep is concurrent or not
    else if (strcmp(argv[i] + 5, "concurrent") == 0)
        gDvm.concurrentMarkSweep = true;
    else if (strcmp(argv[i] + 5, "noconcurrent") == 0)
        gDvm.concurrentMarkSweep = false;
    //Only for GC verify cardtable which is used for marking the concurrent marksweep dirty field
    else if (strcmp(argv[i] + 5, "verifycardtable") == 0)
        gDvm.verifyCardTable = true;
    else if (strcmp(argv[i] + 5, "noverifycardtable") == 0)
        gDvm.verifyCardTable = false; 
    else {
        dvmFprintf(stderr, "Bad value for -Xgc");
        return -1;
    }
    ALOGV("Precise GC configured %s", gDvm.preciseGc ? "ON" : "OFF");
}

主要用於控制:

  • 是否線上程棧上標記物件(precise)
  • 是否對GC進行驗證(xxxVerify)
  • 是否開啟並行GC(concurrent)

http://stackoverflow.com/questions/14235842/how-to-enable-logs-specific-to-garbage-collector-in-dalvikvm