// This is a process only hosting activities that are not visible, // so it can be killed without any disruption. staticfinalintCACHED_APP_MAX_ADJ=906; staticfinalintCACHED_APP_MIN_ADJ=900;
// This is a process currently hosting a backup operation. Killing it // is not entirely fatal but is generally a bad idea. staticfinalintBACKUP_APP_ADJ=300;
// This is a process only hosting components that are perceptible to the // user, and we really want to avoid killing them, but they are not // immediately visible. An example is background music playback. staticfinalintPERCEPTIBLE_APP_ADJ=200;
// This is a process only hosting activities that are visible to the // user, so we'd prefer they don't disappear. staticfinalintVISIBLE_APP_ADJ=100; staticfinalintVISIBLE_APP_LAYER_MAX= PERCEPTIBLE_APP_ADJ - VISIBLE_APP_ADJ - 1;
// This is the process running the current foreground app. We'd really // rather not kill it! staticfinalintFOREGROUND_APP_ADJ=0; ...
// These are the various interesting memory levels that we will give to // the OOM killer. Note that the OOM killer only supports 6 slots, so we // can't give it a different value for every possible kind of process. privatefinalint[] mOomAdj = newint[] { FOREGROUND_APP_ADJ, VISIBLE_APP_ADJ, PERCEPTIBLE_APP_ADJ, BACKUP_APP_ADJ, CACHED_APP_MIN_ADJ, CACHED_APP_MAX_ADJ };
voiddumpTotalsLocked(PrintWriter pw, long now) { pw.println("Run time Stats:"); DumpUtils.dumpSingleTime(pw, " ", mMemFactorDurations, mMemFactor, mStartTime, now); pw.println(); pw.println("Memory usage:"); TotalMemoryUseCollectiontotalMem=newTotalMemoryUseCollection(ALL_SCREEN_ADJ, ALL_MEM_ADJ); computeTotalMemoryUse(totalMem, now); longtotalPss=0; totalPss = printMemoryCategory(pw, " ", "Kernel ", totalMem.sysMemKernelWeight, totalMem.totalTime, totalPss, totalMem.sysMemSamples); totalPss = printMemoryCategory(pw, " ", "Native ", totalMem.sysMemNativeWeight, totalMem.totalTime, totalPss, totalMem.sysMemSamples); for (int i=0; i<STATE_COUNT; i++) { // Skip restarting service state -- that is not actually a running process. if (i != STATE_SERVICE_RESTARTING) { totalPss = printMemoryCategory(pw, " ", DumpUtils.STATE_NAMES[i], totalMem.processStateWeight[i], totalMem.totalTime, totalPss, totalMem.processStateSamples[i]); } }
ok, 然后再考虑某个时间段的使用确定内存使用统计。
对PSS的内核proc.txt有说明:
The “proportional set size” (PSS) of a process is the count of pages it has in memory, where each page is divided by the number of processes sharing it. So if a process has 1000 pages all to itself, and 1000 shared with one other process, its PSS will be 1500.