GC_CONCURRENT何时何地调用?

时间:2014-01-14 08:17:05

标签: android garbage-collection dalvik

我找到了dalvikvm的源代码,但找不到并发GC调用的位置。

我从android git存储库获取的malloc代码

static void gcForMalloc(bool clearSoftReferences)
{
    if (gDvm.allocProf.enabled) {
        Thread* self = dvmThreadSelf();
        gDvm.allocProf.gcCount++;
        if (self != NULL) {
            self->allocProf.gcCount++;
        }
    }
    /* This may adjust the soft limit as a side-effect.
     */
    const GcSpec *spec = clearSoftReferences ? GC_BEFORE_OOM : GC_FOR_MALLOC;
    dvmCollectGarbageInternal(spec);
}

我认为dvmCollectGarbageInternal函数打印GC LOG,但GC_CONCURRENT没有任何内容。

dvmCollectGarbageInternal函数的日志代码

if (!spec->isConcurrent) {
    u4 markSweepTime = dirtyEnd - rootStart;
    u4 gcTime = gcEnd - rootStart;
    bool isSmall = numBytesFreed > 0 && numBytesFreed < 1024;
    ALOGD("%s freed %s%zdK, %d%% free %zdK/%zdK, paused %ums, total %ums",
         spec->reason,
         isSmall ? "<" : "",
         numBytesFreed ? MAX(numBytesFreed / 1024, 1) : 0,
         percentFree,
         currAllocated / 1024, currFootprint / 1024,
         markSweepTime, gcTime);
} else {
    u4 rootTime = rootEnd - rootStart;
    u4 dirtyTime = dirtyEnd - dirtyStart;
    u4 gcTime = gcEnd - rootStart;
    bool isSmall = numBytesFreed > 0 && numBytesFreed < 1024;
    ALOGD("%s freed %s%zdK, %d%% free %zdK/%zdK, paused %ums+%ums, total %ums",
         spec->reason,
         isSmall ? "<" : "",
         numBytesFreed ? MAX(numBytesFreed / 1024, 1) : 0,
         percentFree,
         currAllocated / 1024, currFootprint / 1024,
         rootTime, dirtyTime, gcTime);
}

以上代码来自Android的主分支,而我的nexus手机的Android版本是4.4.2   我想念一下吗?

1 个答案:

答案 0 :(得分:1)