查看缓存的命令
free -m
清理缓存的命令
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
说明:
1>. /proc是一个虚拟文件系统,我们可以通过对它的读写操作作为与kernel实体间进行通信的一种手段。也就是说可以通过修改/proc中的文件,来对当前kernel的行为做出调整。也就是说我们可以通过调整/proc/sys/vm/drop_caches来释放内存。
1>. /proc是一个虚拟文件系统,我们可以通过对它的读写操作作为与kernel实体间进行通信的一种手段。也就是说可以通过修改/proc中的文件,来对当前kernel的行为做出调整。也就是说我们可以通过调整/proc/sys/vm/drop_caches来释放内存。
0 – 不释放
1 – 释放页缓存
2 – 释放dentries和inodes
3 – 释放所有缓存
1 – 释放页缓存
2 – 释放dentries和inodes
3 – 释放所有缓存
2>. 关于drop_caches的官方说明如下:
Writing to this file causes the kernel to drop clean caches,dentries and inodes from memory,causing that memory to becomefree.
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 first.
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 first.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。