在我的系統上,它們大部分是由ION(取代pmem)引起的。如果離子調試與你的內核中啓用,你可以用這個腳本計算您的ION用法:
adb shell cat /d/ion/heaps/system|perl -ne 'chomp; if (m/pages in.*pool = (\d+) total/) {$x += $1;} if (m/^\s+total\s+(\d+)$/) {$y += $1} END {printf "use: %d kb, cache: %d kb; total: %d kb", $y/1024, $x/1024, ($x + $y)/1024}'
事實上,由司機完成和跟蹤任何內核頁分配將不會被內核跟蹤,從而計算爲失去的公羊。
當我停止系統服務器後,我用另一個.awk腳本來計算丟失的內存(dumpsys meminfo將需要meminfo服務,因此不再工作),並且丟失的內存非常緊跟ION調試輸出:
#!/usr/bin/awk
BEGIN {
types["MemTotal"] = 1;
types["Pss"] = 1;
types["MemFree"] = 1;
types["Cached"] = 1;
types["Buffers"] = 1;
types["Shmem"] = 1;
types["Slab"] = 1;
}
## start code-generator "^\\s *#"
#echo
# for x in Pss MemTotal MemFree Cached Buffers Shmem Slab; do
# cat << EOF
#/$x:/{
# hash["$x"] += \$2;
# next
#}
#
#EOF
# done
## end code-generator
## start generated code
/Pss:/{
hash["Pss"] += $2;
next
}
/MemTotal:/{
hash["MemTotal"] += $2;
next
}
/MemFree:/{
hash["MemFree"] += $2;
next
}
/Cached:/{
hash["Cached"] += $2;
next
}
/Buffers:/{
hash["Buffers"] += $2;
next
}
/Shmem:/{
hash["Shmem"] += $2;
next
}
/Slab:/{
hash["Slab"] += $2;
next
}
## end generated code
END {
lost = 0;
for (type in types) {
if (type == "MemTotal") {
lost += hash[type];
} else {
lost -= hash[type];
}
}
print "lost: " lost " kB\n";
}
我也檢查了一遍後,我強制內核內存adb shell sh -c 'echo 3 > /proc/sys/vm/drop_caches'
收縮,結果依然非常接近。
它是'lost = total - lost - free',即它是會計機制無法解釋的東西。我不知道「丟失」是否合適,但dumpsys meminfo無法弄清楚它被用於什麼。 – fadden