vmtouch--the Virtual Memory Toucher
2011-12-16 10:29
447 查看
给大家介绍个好玩的工具--vmtouch,可以查看某个文件在内存的使用。下面是摘录其网站,有兴趣的童鞋可以自己研究下
下载源码wget http://hoytech.com/vmtouch/vmtouch.c
编译gcc -Wall -O3 -o vmtouch vmtouch.c
cp vmtouch /usr/local/bin/
Example 1
How much of the /bin/ directory is currently in cache?
$ vmtouch /bin/ Files: 92 Directories: 1 Resident Pages: 348/1307 1M/5M 26.6% Elapsed: 0.003426 seconds
Example 2
How much of big-dataset.txt is currently in memory?
$ vmtouch -v big-dataset.txt big-dataset.txt [ ] 0/42116 Files: 1 Directories: 0 Resident Pages: 0/42116 0/164M 0% Elapsed: 0.005182 seconds None of it. Now let's bring part of it into memory with tail: $ tail -n 10000 big-dataset.txt > /dev/null Now how much? $ vmtouch -v big-dataset.txt big-dataset.txt [ oOOOOOOO] 4950/42116 Files: 1 Directories: 0 Resident Pages: 4950/42116 19M/164M 11.8% Elapsed: 0.006706 seconds vmtouch tells us that 4950 pages at the end of the file are now resident in memory.
Example 3
Let's bring the rest of big-dataset.txt into memory (pressing enter a few times to illustrate the animated progress bar you will see on your terminal):
$ vmtouch -vt big-dataset.txt big-dataset.txt [OOo oOOOOOOO] 6887/42116 [OOOOOOOOo oOOOOOOO] 10631/42116 [OOOOOOOOOOOOOOo oOOOOOOO] 15351/42116 [OOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 19719/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 24183/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 28615/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 31415/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 36775/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 39431/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 42116/42116 Files: 1 Directories: 0 Touched Pages: 42116 (164M) Elapsed: 12.107 seconds
Example 4
We have 3 big datasets, a.txt, b.txt, and c.txt but only 2 of them will fit in memory at once. If we have a.txt and b.txt in memory but would now like to work withb.txt and c.txt, we could just start loading up c.txt but then our system would evict pages from both a.txt (which we want) and b.txt (which we don't want).
So let's give the system a hint and evict a.txt from memory, making room for c.txt:
$ vmtouch -ve a.txt Evicting a.txt Files: 1 Directories: 0 Evicted Pages: 42116 (164M) Elapsed: 0.076824 seconds
Example 5
Daemonise and lock all files in a directory into physical memory:
vmtouch -dl /var/www/htdocs/critical/
本文出自 “star&storage” 博客,请务必保留此出处http://taotao1240.blog.51cto.com/731446/743249
下载源码wget http://hoytech.com/vmtouch/vmtouch.c
编译gcc -Wall -O3 -o vmtouch vmtouch.c
cp vmtouch /usr/local/bin/
Example 1
How much of the /bin/ directory is currently in cache?
$ vmtouch /bin/ Files: 92 Directories: 1 Resident Pages: 348/1307 1M/5M 26.6% Elapsed: 0.003426 seconds
Example 2
How much of big-dataset.txt is currently in memory?
$ vmtouch -v big-dataset.txt big-dataset.txt [ ] 0/42116 Files: 1 Directories: 0 Resident Pages: 0/42116 0/164M 0% Elapsed: 0.005182 seconds None of it. Now let's bring part of it into memory with tail: $ tail -n 10000 big-dataset.txt > /dev/null Now how much? $ vmtouch -v big-dataset.txt big-dataset.txt [ oOOOOOOO] 4950/42116 Files: 1 Directories: 0 Resident Pages: 4950/42116 19M/164M 11.8% Elapsed: 0.006706 seconds vmtouch tells us that 4950 pages at the end of the file are now resident in memory.
Example 3
Let's bring the rest of big-dataset.txt into memory (pressing enter a few times to illustrate the animated progress bar you will see on your terminal):
$ vmtouch -vt big-dataset.txt big-dataset.txt [OOo oOOOOOOO] 6887/42116 [OOOOOOOOo oOOOOOOO] 10631/42116 [OOOOOOOOOOOOOOo oOOOOOOO] 15351/42116 [OOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 19719/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 24183/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 28615/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 31415/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 36775/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 39431/42116 [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 42116/42116 Files: 1 Directories: 0 Touched Pages: 42116 (164M) Elapsed: 12.107 seconds
Example 4
We have 3 big datasets, a.txt, b.txt, and c.txt but only 2 of them will fit in memory at once. If we have a.txt and b.txt in memory but would now like to work withb.txt and c.txt, we could just start loading up c.txt but then our system would evict pages from both a.txt (which we want) and b.txt (which we don't want).
So let's give the system a hint and evict a.txt from memory, making room for c.txt:
$ vmtouch -ve a.txt Evicting a.txt Files: 1 Directories: 0 Evicted Pages: 42116 (164M) Elapsed: 0.076824 seconds
Example 5
Daemonise and lock all files in a directory into physical memory:
vmtouch -dl /var/www/htdocs/critical/
本文出自 “star&storage” 博客,请务必保留此出处http://taotao1240.blog.51cto.com/731446/743249
相关文章推荐
- vmtouch - the Virtual Memory Toucher
- The summary of virtual memory
- What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memor
- elasticsearch max virtual memory areas vm.max_map_count [65530] is too low, increase to at le
- memory management in the java HotSpot Virtual Machine(中文翻译)
- understanding the linux virtual memory management 图序
- max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- My priliminary understanding of the relationship between virtual address and physical memory address
- Ubuntu elasticsearch max virtual memory areas vm.max_map_count [65530] is too low, increase to at le
- 重读<Understanding The Linux Virtual Memory Manager>笔记
- Windows NT File System Internals----Chapter 5 The NT Virtual Memory Manage
- android Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.
- the memory of virtual base class of C++
- Understanding The Linux Virtual Memory Manager
- 重读<Understanding The Linux Virtual Memory Manager>笔记
- max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
- max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- [VM]Get Password from Virtual Machine Memory
- ios About the Virtual Memory System
- Understanding The Linux Virtual Memory Manager