-
- VSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)
- RSS - Resident Set Size 实际使用物理内存(包含共享库占用的内存)
- PSS - Proportional Set Size 实际使用的物理内存(比例分配共享库占用的内存)
- USS - Unique Set Size 进程独自占用的物理内存(不包含共享库占用的内存)
/proc/meminfo
/proc/pagetypeinfo
all page info of free pages allocated by buddy algorithm. the sum of the pages equal free mem.
/proc/vmstat
pgpgin: the total page number for pages of reading from emmc
pgpgout; the total page number for pages of writing to emmc
procrank: list out the memory usage of Linux processes in order from highest to lowest usage.procmem: display the memory usage of the specific process.
vmstat: 是Virtual Meomory Statistics(虚拟内存统计)的缩写, 1、观察磁盘活动情况 2、观察cpu活动情况 3. 进程运行情况。 包括中断数,进程切换数,idle, io_wait, block的进程数等。其中,bi/bo 是以KB/s 为单位的。vmstat 是通过从 /proc/vmstat 中多次读取的pgpgin/pgpgout(分别对应bi, bo)值, 并与上一次读取的值做差,再除以这两次的时间间隔,得到bi/bo.而pgpgin/pgpgout 是以KB 为单位的。
lsof: list open files, 是一个列出当前系统打开文件的工具,结合grep使用。
fuser : 可以显示出当前哪个程序在使用磁盘上的某个文件,挂载点,甚至网络端口。也可杀死使用某文件或某磁盘的进程。
stat :以文字的格式来显示inode的内容,包括文件/文件系统的大小,块数(sectors), uid,gid and so on.
ls -i: 显示文件的inode 号。
find -inum **: 利用inode来查找文件。
nohup : nohup program &, 可以使程序不间断地运行,即使shell退出
debugfs: 调试恢复文件系统的工具,可以icheck ncheck stat 等命令来查询 block号(非sector),inode号及文件之间的关联。
函数 shrink_zone()
其中,shrink_zone() 函数是 Linux 操作系统实现页面回收的最核心的函数之一,它实现了对一个内存区域的页面进行回收的功能,该函数主要做了两件事情:
- 将某些页面从 active 链表移到 inactive 链表,这是由函数 shrink_active_list() 实现的。
- 从 inactive 链表中选定一定数目的页面,将其放到一个临时链表中,这由函数 shrink_inactive_list() 完成。该函数最终会调用 shrink_page_list() 去回收这些页面。
-
是用来回收磁盘缓存所占用的页面的。Linux 操作系统并不清楚这类页面是如何使用的,所以如果希望操作系统回收磁盘缓存所占用的页面,那么必须要向操作系统内核注册 shrinker 函数,shrinker 函数会在内存较少的时候主动释放一些该磁盘缓存占用的空间。函数 shrink_slab() 会遍历 shrinker 链表,从而对所有注册了 shrinker 函数的磁盘缓存进行处理。
从实现上来看,shrinker 函数和 slab 分配器并没有固定的联系,只是当前主要是 slab 缓存使用 shrinker 函数最多。
shrink_dcache_memory();
shrink_icache_memory();
ashmem_shrink();
mb_cache_shrink_fn()
shrink_dqcache_memory();
lowmem_shrink();