首页 技术 正文
技术 2022年11月12日
0 收藏 731 点赞 2,697 浏览 1904 个字

基本内存术语解读

1> free -m

  同样是做为缓存,buffers和cache又有啥区别呢?

  于是又查了些资料,发现buffers实际应该是叫“缓冲”,其英文解释是:A buffer is something that has yet to be “written” to disk.

  就是说,buffers是将要写入硬盘中的数据缓存。

  而cache的英文解释:A cache is something that has been “read” from the disk and stored for later use.

  就是说,cache是从硬盘或者存储设备读进计算机后缓存在内存中的数据。

  想起看《计算机组成原理》的时候,有看到因特尔的cpu与内存之间有cache,这之间好像有什么区别的样子。

  继续查资料,发现了page cache 和 buffer cache。简单说来,page cache用来缓存文件数据,buffer cache用来缓存磁盘数据。在有文件系统的情况下,对文件操作,那么数据会缓存到page cache,如果直接采用dd等工具对磁盘进行读写,那么数据会缓存到buffer cache。

  对于cache和buffer,cached是cpu与内存间的,buffer是内存与磁盘间的,都是为了解决速度不对等的问题。

  在free中,buffer 是buffer cache的内存,是块设备的读写缓冲区;cache是page cache的内存, 文件系统的cache。

  关于buffer与chche,这里就不多说了,最后的链接5里讲得挺清楚了。

  这里还有一个名词,Swap,即虚拟内存。当物理内存不够用的时候,就要释放掉一部分空间,以供当前运行程序使用。这些被释放掉的内存的数据就被临时保存在虚拟内存中。但是,并非所有的数据都全被保存,只有那些使用malloc或new生成的对象,他们在文件中并没有相应的“储备”文件,被称为匿名内存数据,需要临时地存进Swap。故Swap又称匿名数据交换空间。在链接3中有其说明。

2> top

动态查看系统的资源使用情况

linux下查看内存使用情况

3> vmstat –  Report virtual memory statistics

查看虚拟内存使用情况

linux下查看内存使用情况

参数解读:

r The number of processes waiting for run time.   处于运行队列中的内核线程数目(进程数)。
b The number of processes in uninterruptible sleep. 置于等待队列(等待资源、等待输入/输出)的内核线程数目。 处于block队列中不可中断的进程数
swpd the amount of virtual memory used.  可用的虚拟交换内存
free the amount of idle memory. 空闲内存
buff the amount of memory used as buffers. 已用缓冲数目
cache the amount of memory used as cache. 已用缓存数目
si Amount of memory swapped in from disk (/s). ���磁盘到内存的交换页数目 (单位/S)
so Amount of memory swapped to disk (/s). 从交换内存到磁盘的交换页数目(单位/S)
bi Blocks received from a block device (blocks/s). 接收到块设备的块数(块/秒)
bo Blocks sent to a block device (blocks/s). 发送到块设备的块数(块/秒)
in The number of interrupts per second, including the clock. 每秒中断数,包括时钟中断
cs The number of context switches per second. 每秒上下文切换数
us Time spent running non-kernel code. (user time, including nice time) 用户时间,处于用户模式的时间百分比
sy Time spent running kernel code. (system time) 系统时间,处于内核模式的时间百分比
id Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time. CPU空闲时间,空闲时间百分比
wa Time spent waiting for IO. Prior to Linux 2.5.41, included in idle. CPU 空闲时间,在此期间系统有未完成的磁盘/NFS I/O 请求
wt Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,949
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,475
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,288
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,103
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,735
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,770