什么是背后的“失落的RAM”出现在Dumpsys meminfo中的概念?出现在、概念、RAM、meminfo

2023-09-07 12:23:02 作者:与孤独和好

正如我刚才提到的问题,忘记RAM 出现在 Dumpsys meminfo中

什么是背后的失落的RAM出现在Dumpsys概念meminfo中? 什么是它在奇巧的意义。如何可以回收和使用?

样品dumpsys呈现失落的RAM。

 总内存:998096 KB
 免费内存:574945 KB(145869缓存PSS + 393200缓存+ 35876免费)

 二手内存:392334 KB(240642使用PSS + 107196缓冲区+ 3856 SHMEM + 40640板)

 失落的RAM:30817 KB

   调整:64(大型384),OOM 122880 KB,恢复限40960 KB(高端-GFX)
 

解决方案

在我的系统,他们大多是通过离子引起的(代替PMEM)。如果离子调试启用了你的内核,就可以计算出使用这个脚本您的ION用法:

亚行外壳猫/ D /离子/堆/系统| perl的-ne'格格;如果(M /在*池=(\ d +)共/页。){$ X + = $ 1;}如果(M / ^ \ S +总\ S +(\ d +)$ /){$ Y + = $ 1} END {printf的使用方法:%D KB,缓存:%D KB;累计数:%d KB,$ Y / 1024,$ X / 1024($ X + $ Y)/ 1024}

如何对Android客户端性能优化 看这篇就够了

在事实上,由司机完成和跟踪任何内核页分配将不会由内核跟踪,从而计数为失去压头

在我停止系统服务器,我用另一种.awk脚本来计算丢失的RAM(dumpsys meminfo中会要求meminfo中服务,因此将不再工作),而失去了公羊是非常密切关注ION调试输出:

 #!的/ usr / bin中/ AWK

开始 {
    类型[MemTotal] = 1;
    类型[诗一] = 1;
    类型[MemFree] = 1;
    类型[网页快照] = 1;
    类型[缓冲区] = 1;
    类型[SHMEM] = 1;
    类型[板] = 1;
}


##开始code-发电机^ \\ S *#
#回声
#对于x在PSS中MemTotal MemFree缓存缓冲区SHMEM板;做
#猫<< EOF
#/ $ X:/ {
#哈希[$ X] + = \ $ 2;
# 下一个
#}
#
#EOF
#完成
##月底code-发生器
##开始产生code

/ PSS:/ {
    哈希[诗一] + = $ 2;
    下一个
 }

 / MemTotal:/ {
     哈希[MemTotal] + = $ 2;
     下一个
 }

 / MemFree:/ {
     哈希[MemFree] + = $ 2;
     下一个
 }

 /缓存:/ {
     哈希[网页快照] + = $ 2;
     下一个
 }

 /缓冲器:/ {
     哈希[缓冲器] + = $ 2;
     下一个
 }

 / SHMEM:/ {
     哈希[SHMEM] + = $ 2;
     下一个
 }

 /板坯:/ {
     哈希[板] + = $ 2;
     下一个
 }


##月底产生code

结束 {
    丢失= 0;
    对于(类型类型){
        如果(类型==MemTotal){
            失去+ =散[类型];
        } 其他 {
            失去了 -  =散[类型];
        }
    }
    打印丢失:丢失KB \ N的;
}
 

我还检查了一遍后,我强制内核内存与收缩亚行外壳SH -c回响3>的/ proc / SYS / VM / drop_caches,其结果仍然是非常接近的。

As I have mentioned in question, Lost RAM appears in Dumpsys meminfo.

What is the concept behind "Lost RAM" which appears in Dumpsys meminfo? What is its significance in Kitkat. How it can be reclaimed and used?

Sample dumpsys showing "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). If ion debug is enabled with your kernel, you can calculate your ION usage with this script:

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:

#!/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.