简体   繁体   English

Dumpsys meminfo中出现的“ Lost RAM”背后的概念是什么?

[英]What is the concept behind “Lost RAM” which appears in Dumpsys meminfo?

As I have mentioned in question, Lost RAM appears in Dumpsys meminfo . 正如我所提到的, Dumpsys meminfo出现了RAM丢失

  1. What is the concept behind “Lost RAM” which appears in Dumpsys meminfo? Dumpsys meminfo中出现的“ Lost RAM”背后的概念是什么?
  2. What is its significance in Kitkat. 在基特凯有什么意义。 How it can be reclaimed and used? 如何回收和使用它?

Sample dumpsys showing "Lost RAM". 示例dumpsys显示“ Lost RAM”。

Total RAM: 998096 kB
 Free RAM: 574945 kB (145869 cached pss + 393200 cached + 35876 free)

 Used RAM: 392334 kB (240642 used pss + 107196 buffers + 3856 shmem + 40640 slab)

 Lost RAM: 30817 kB

   Tuning: 64 (large 384), oom 122880 kB, restore limit 40960 kB (high-end-gfx)

On my system, they are caused mostly by ION (which replaces pmem). 在我的系统上,它们主要是由ION(代替pmem)引起的。 If ion debug is enabled with your kernel, you can calculate your ION usage with this script: 如果您的内核启用了离子调试,则可以使用以下脚本来计算您的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}'

In fact, any kernel page allocation done and tracked by drivers will not be tracked by the kernel, thus counting for the lost ram. 实际上,内核不会跟踪任何由驱动程序完成和跟踪的内核页面分配,因此计入了丢失的内存。

After I stop the system server, I used another .awk script to calculate lost ram (dumpsys meminfo will require the meminfo service and thus won't work anymore), and the lost ram is very closely following ION debug output: 停止系统服务器后,我使用了另一个.awk脚本来计算丢失的ram(dumpsys meminfo将需要meminfo服务,因此将不再起作用),并且丢失的ram与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";
}

I also checked again after I force a kernel memory shrink with adb shell sh -c 'echo 3 > /proc/sys/vm/drop_caches' , the results are still very close. 我还用adb shell sh -c 'echo 3 > /proc/sys/vm/drop_caches'强制缩小了内核内存后再次检查,结果仍然非常接近。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM