通常内存关系是:
普通机器:total=used+free
虚拟机器:total=used+free+buff/cache

[260190@w26-260190 bin]$ free -h
total used free shared buff/cache available
Mem: 31G 5.7G 18G 562M 7.0G 24G
Swap: 15G 57M 15G
[260190@w26-260190 bin]$
清除cache内存
sync;echo 1 > /proc/sys/vm/drop_caches
sync;echo 2 > /proc/sys/vm/drop_caches
sync;echo 3 > /proc/sys/vm/drop_caches
这个文件可以设置的值分别为1、2、3。它们所表示的含义为:
echo 1 > /proc/sys/vm/drop_caches # 表示清除pagecache。
echo 2 > /proc/sys/vm/drop_caches # 表示清除回收slab分配器中的对象(包括目录项缓存和inode缓存)。slab分配器是内核中管理内存的一种机制,其中很多缓存数据实现都是用的pagecache。
echo 3 > /proc/sys/vm/drop_caches # 表示清除pagecache和slab分配器中的缓存对象。
[root@w26-260190 bin]# free -h
total used free shared buff/cache available
Mem: 31G 5.4G 24G 576M 1.0G 24G
Swap: 15G 57M 15G
[root@w26-260190 bin]#
本文深入解析了普通机器和虚拟机器的内存使用模型,详细说明了内存的total、used、free、buff/cache等概念,并提供了清除cache内存的具体方法,包括pagecache和slab分配器缓存的清除。
5417

被折叠的 条评论
为什么被折叠?



