当前位置: 代码迷 >> 综合 >> Linux-ubuntu 释放linux的buff/cache
  详细解决方案

Linux-ubuntu 释放linux的buff/cache

热度:54   发布时间:2024-02-19 16:40:25.0
$ free -htotal        used        free      shared  buff/cache   available
Mem:           7.7G        1.4G        4.3G         59M        1.9G        5.8G
Swap:          7.9G          0B        7.9G

含义注释:
total 内存总数
used 已经使用的内存数
free 空闲的内存数
shared 多个进程共享的内存总额
buffers Buffer Cache和cached Page Cache 磁盘缓存的大小
-buffers/cache (已用)的内存数:used - buffers - cached
+buffers/cache(可用)的内存数:free + buffers + cached
可用的memory=free memory+buffers+cached 

释放方法有三种(系统默认值是0):

To free pagecache: echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes: echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes: echo 3 > /proc/sys/vm/drop_caches

注意:在清空缓存前我们需要在linux系统中执行一下sync命令,将缓存中的未被写入磁盘的内容写到磁盘上

 

cat /proc/sys/vm/drop_caches0
echo 3 > /proc/sys/vm/drop_caches

 

cat /proc/sys/vm/drop_caches
free -htotal        used        free      shared  buff/cache   available
Mem:           7.7G        1.4G        5.7G         58M        530M        5.9G
Swap:          7.9G          0B        7.9G

 

  相关解决方案