【随手记录】释放pagecache

 

在执行后面三条命令之前一定要先执行sync命令
(描述:sync 命令运行 sync 子例程,如果必须停止系统,则运行sync 命令以确保文件系统的完整性
sync 命令将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-Node、已延迟的块 I/O 和读写映射文件)

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

This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable. If you run "sync" first to flush them out to disk, these drop operations will tend to free more memory.
这是一种无损操作,只会释放完全未使用的东西。 脏对象将继续使用,直到将其写到磁盘上并且无法释放。 如果先运行“同步”以将它们刷新到磁盘,则这些删除操作将倾向于释放更多的内存。

如果有需要可以写个脚本,然后加入到crontab定时清理

posted @ 2020-11-15 20:40  空知大仙人  阅读(179)  评论(0编辑  收藏  举报