加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码网 (https://www.900php.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

都说Linux是吃内存大户,可你知道具体是哪些进程吃掉了吗?

发布时间:2019-10-26 04:49:52 所属栏目:Windows 来源:Mike
导读:副标题#e# 一个经常被问到的 Linux 问题:为啥 Linux 系统没运行多少程序,显示的可用内存这么少? 其实 Linux 与 Windows 的内存管理不同,会尽量缓存内存以提高读写性能,通常叫做 Cache Memory。 比较老的资料都会介绍 Linux 的 Cache 占用很多并没有关

安装 Vmtouch

  1. $ git clone https://github.com/hoytech/vmtouch  
  2. $ cd vmtouch  
  3. $ make  
  4. $ sudo make install 

使用 Vmtouch

  1. vmtouch 命令语法
  1. $ vmtouch  
  2. vmtouch: no files or directories specified  
  3. vmtouch v1.0.2 - the Virtual Memory Toucher by Doug Hoyte  
  4. Portable file system cache diagnostics and control  
  5. Usage: vmtouch [OPTIONS] ... FILES OR DIRECTORIES ...  
  6. Options:  
  7.   -t touch pages into memory  
  8.   -e evict pages from memory  
  9.   -l lock pages in physical memory with mlock(2)  
  10.   -L lock pages in physical memory with mlockall(2)  
  11.   -d daemon mode  
  12.   -m max file size to touch  
  13.   -p use the specified portion instead of the entire file  
  14.   -f follow symbolic links  
  15.   -h also count hardlinked copies  
  16.   -w wait until all pages are locked (only useful together with -d)  
  17.   -v verbose  
  18.   -q quiet 

  2.   一些使用的例子

由于 vmtouch 直接支持目录级查询,所以使用起来简单得多了。

  •  查看 /tmp 目录在内存中的缓存
  1. $ vmtouch /tmp/  
  2. vmtouch: WARNING: skipping non-regular file: /tmp/ssh-GgJnCEkWMQC2/agent.1068  
  3.            Files: 17  
  4.      Directories: 7  
  5.   Resident Pages: 4780/4780  18M/18M  100%  
  6.          Elapsed: 0.001006 seconds 

如果需要查看更详细信息,可以使用 -v 参数。

  1. $ vmtouch -v /tmp/ 
  •  查看一个文件被缓存了多少
  1. $ vmtouch -v ~/Downloads/phoronix-test-suite_6.0.1_all.deb   
  2. /home/neo/Downloads/phoronix-test-suite_6.0.1_all.deb  
  3. [                                            ] 0/132  
  4.            Files: 1  
  5.      Directories: 0  
  6.   Resident Pages: 0/132  0/528K  0%  
  7.          Elapsed: 0.000117 seconds 
  •  把指定的文件缓存起来
  1. $ vmtouch -vt ~/Downloads/phoronix-test-suite_6.0.1_all.deb   
  2. /home/neo/Downloads/phoronix-test-suite_6.0.1_all.deb  
  3. [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 132/132  
  4.            Files: 1  
  5.      Directories: 0  
  6.    Touched Pages: 132 (528K)  
  7.          Elapsed: 0.007935 seconds 
  •  把缓存中指定的数据驱逐出去
  1. $ vmtouch -ve ~/Downloads/phoronix-test-suite_6.0.1_all.deb   
  2. Evicting /home/neo/Downloads/phoronix-test-suite_6.0.1_all.deb  
  3.            Files: 1  
  4.      Directories: 0  
  5.    Evicted Pages: 132 (528K)  
  6.          Elapsed: 0.000109 seconds 

更多关于 vmtouch 使用的具体信息,你可以参考官网:https://hoytech.com/vmtouch/

如果你还有更多 Linux 下查看 Cache 或 Buffer 占用的方法,请直接留言告诉我们哟!

(编辑:源码网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读