linux – 了解缓存中的程序

linux – 了解缓存中的程序,第1张

概述我现在有RAM和SWAP这种情况: $free -h total used free shared buffers cachedMem: 7,7G 7,5G 159M 100M 75M 5,9G-/+ buffers/cache: 我现在有RAM和SWAP这种情况:

$free -h             total       used       free     shared    buffers     cachedMem:          7,7G       7,5G       159M       100M        75M       5,9G-/+ buffers/cache:       1,5G       6,1GSwap:         7,9G       408M       7,5G

我想知道……

有没有办法知道哪些程序/数据是RAM缓存的和/或它们来自哪个进程?

我的想法是,由于它们可以重复使用,因此应该有一种“识别”它们的方法.
但我的知识实在太小,无法知道如何.

非常感谢你提前.

解决方法

is there a way to kNow what programs/data are RAM-cached and/or from which process do they come from?

有一个程序http://hoytech.com/vmtouch/ vmtouch.它提供信息文件缓存中文件的百分比.你可能需要编译它.这是我的电脑上的示例:

在读取不在缓存中的文件之前:

$vmtouch -v  /usr/share/dict/linux.words/usr/share/dict/linux.words[                                                          ] 0/1210           files: 1     DirectorIEs: 0  ResIDent Pages: 0/1210  0/4M  0%         Elapsed: 0.000169 seconds

从文件中读取一些数据后:

$tail -n 10000 /usr/share/dict/linux.words >/dev/null$vmtouch -v  /usr/share/dict/linux.words/usr/share/dict/linux.words[                                                        oO] 24/1210           files: 1     DirectorIEs: 0  ResIDent Pages: 24/1210  96K/4M  1.98%         Elapsed: 0.000152 seconds

vmtouch frist为文件调用nmap,然后使用mincore系统调用来确定文件或其某些页面是否驻留在内存中:

男人mincore:

DESCRIPTION

mincore() returns a vector that indicates whether pages of the calling process’s virtual memory are resIDent in core (RAM),and so will not cause a disk access (page fault) if referenced. The kernel returns resIDency information about the pages starting at the address addr,and continuing for length bytes.

总结

以上是内存溢出为你收集整理的linux – 了解缓存中的程序全部内容,希望文章能够帮你解决linux – 了解缓存中的程序所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1019707.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存