Reputation: 215
I have this situation with RAM and SWAP at the moment:
$ free -h
total used free shared buffers cached
Mem: 7,7G 7,5G 159M 100M 75M 5,9G
-/+ buffers/cache: 1,5G 6,1G
Swap: 7,9G 408M 7,5G
And I was wondering...
Is there a way to know what programs/data are RAM-cached and/or from which process do they come from?
My idea is that, since they are re-usable, there should be a way to "identify" them.
But my knowledge is really too small to know how.
Thank you very much in advance.
Upvotes: 4
Views: 1068
Reputation:
is there a way to know what programs/data are RAM-cached and/or from which process do they come from?
There is a program http://hoytech.com/vmtouch/ vmtouch
. It gives information how much percent of a file in the file cache. You probably need to compile it. This is example on my computer:
Before reading a file which is not in the cache:
$ 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
After reading some data from the file:
$ 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 calls nmap
for a file and then uses mincore
system call to determine if a file or some of its pages are resident in memory:
man 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.
Upvotes: 2