Linux cache内存简介以及释放
来源:互联网 发布:mac数据恢复 编辑:程序博客网 时间:2024/05/23 21:18
关于Linux cached内存简析
原文:http://www.2cto.com/os/201204/126594.html 点击打开链接
测试MBS系统,AP的weblogic 只是设置了1.5G内存,但是经过3次稳定性测试,内存的利用率达到99%。
nmon的监控揭发发现存在5.6G的cached内存,下面介绍一下:
Linux与Windows不同,会存在缓存内存,通常叫做Cache Memory。有些时候你会发现没有什么程序在运行,但是使用top或free命令看到可用内存会很少。 www.2cto.com
什么是Cache Memory(缓存内存):
当你读写文件的时候,Linux内核为了提高读写效率与速度,会将文件在内存中进行缓存,这部分内存就是Cache Memory(缓存内存)。即使你的程序运行结束后,Cache Memory也不会自动释放。这就会导致你在Linux系统中程序频繁读写文件后,你会发现可用物理内存会很少。
其实这缓存内存(Cache Memory)在你需要使用内存的时候会自动释放,所以你不必担心没有内存可用。如果你希望手动去释放Cache Memory(缓存内存)的话也是有办法的。
释放Cache Memory(缓存内存):
用下面的命令可以释放Cache Memory:
[rootmin@localhost~]#echo 3 > /proc/sys/vm/drop_caches
Linux中如何释放cache内存
因为LINUX的内核机制,一般情况下不需要特意去释放已经使用的cache。这些cache起来的内容可以增加文件以及的读写速度。
先说下free命令怎么看内存
[rootmin@localhost~]# free
total used free shared buffers cached
Mem: 515588 295452 220136 0 2060 64040
-/+ buffers/cache: 229352 286236
Swap: 682720 112 682608
其中第一行用全局角度描述系统使用的内存状况:
total——总物理内存 www.2cto.com
used——已使用内存,一般情况这个值会比较大,因为这个值包括了cache+应用程序使用的内存
free——完全未被使用的内存
shared——应用程序共享内存
buffers——缓存,主要用于目录方面,inode值等(ls大目录可看到这个值增加)
cached——缓存,用于已打开的文件
注意:
total=used+free
used=buffers+cached (maybe add shared also)
第二行描述应用程序的内存使用:
前个值表示-buffers/cache——应用程序使用的内存大小,used减去缓存值
后个值表示+buffers/cache——所有可供应用程序使用的内存大小,free加上缓存值
注意
-buffers/cache=used-buffers-cached
+buffers/cache=free+buffers+cached
第三行表示swap的使用: www.2cto.com
used——已使用
free——未使用
cache释放:
1. To free pagecache:
[rootmin@localhost~]#echo 1 > /proc/sys/vm/drop_caches
2. To free dentries and inodes:
[rootmin@localhost~]#echo 2 > /proc/sys/vm/drop_caches
3. To free pagecache, dentries and inodes:
[rootmin@localhost~]#echo 3 > /proc/sys/vm/drop_caches
说明,释放前最好sync一下,防止丢数据
Linux下cache内存释放
原文:http://www.2cto.com/os/201108/101147.html 点击打开链接
/proc是一个虚拟文件系统,我们可以通过对它的读写操作做为与kernel 实体间进行通信的一种手段.也就是说可以通过修改/proc中的文 件,来对当前kernel的行为做出调整.那么我们可以通过调整/proc/sys/vm/drop_caches来释放内存.操作如下:
[root@server test]# cat /proc/sys/vm/drop_caches
0
首先,/proc/sys /vm/drop_caches的值,默认为0
[root@server test]# sync
手动执行sync命令(描述:sync 命令运行 sync 子例程。如果必须停止系统,则运行 sync 命令以确保文件系统的完整性。sync 命令将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件)
[root@server test]# echo 3 > /proc/sys/vm/drop_caches
[root@server test]# cat /proc/sys/vm/drop_caches
3
将/proc/sys/vm/drop_caches值设为3
[root@server test]# free -m
total used free shared buffers cached
Mem: 249 66 182 0 0 11
-/+ buffers/cache: 55 194
Swap: 511 0 511
再来运行free命令,发现现在的used为66MB,free为182MB,buffers为0MB,cached为11MB.那么有效的释放了 buffer和cache.
有关/proc/sys/vm/drop_caches的用法在下面进行了说明
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync(8) first.
[root@server test]# cat /proc/sys/vm/drop_caches
0
首先,/proc/sys /vm/drop_caches的值,默认为0
[root@server test]# sync
手动执行sync命令(描述:sync 命令运行 sync 子例程。如果必须停止系统,则运行 sync 命令以确保文件系统的完整性。sync 命令将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件)
[root@server test]# echo 3 > /proc/sys/vm/drop_caches
[root@server test]# cat /proc/sys/vm/drop_caches
3
将/proc/sys/vm/drop_caches值设为3
[root@server test]# free -m
total used free shared buffers cached
Mem: 249 66 182 0 0 11
-/+ buffers/cache: 55 194
Swap: 511 0 511
再来运行free命令,发现现在的used为66MB,free为182MB,buffers为0MB,cached为11MB.那么有效的释放了 buffer和cache.
有关/proc/sys/vm/drop_caches的用法在下面进行了说明
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync(8) first.
0 0
- Linux cache内存简介以及释放
- LINUX释放CACHE内存
- Linux释放cache内存
- linux下释放cache内存
- linux下释放cache内存
- linux下释放cache内存
- linux下释放cache内存
- linux下释放cache内存
- linux下释放cache内存
- linux下释放cache内存
- linux下释放cache内存
- linux下释放cache内存
- 手动释放linux内存cache
- 手动释放linux内存cache
- 手动释放linux内存cache
- linux下释放cache内存
- Linux-手动释放linux内存cache
- Linux中如何释放cache内存 free
- 黑马程序员—[Android就业薪资] Android32期,毕业5个工作日,就业率48.65%,平均薪水9905元!
- 黑马程序员,黑马论坛----黑马.Net9期毕业60天,就业率已达100%,平均薪水6236.17元
- hdu 1065_ceil的使用
- 压力测试tps性能下降问题解决方案
- 【Android开发】解决安卓android.os.NetworkOnMainThreadException
- Linux cache内存简介以及释放
- 批处理-整理
- openGL学习笔记6 bmp 2D纹理贴图
- 操作系统面试题总结
- oracle 报错问题汇总
- 关于Build Active Architecture Only属性
- 黑马程序员,黑马论坛----黑马.Net8期,就业率98.61%,平均薪水5722元!
- 黑马程序员—[Android就业薪资] Android29期,毕业28天,100%全部就业,平均薪水10268元!
- Netstat命令详解