您的位置:首页 > 运维架构 > Linux

手动释放Linux内存

2016-12-26 13:55 453 查看
1. 执行sync命令

sync

说明:使用sync命令以确保文件系统的完整性,sync 命令运行 sync 子例程,将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件。

2. 修改/proc/sys/vm/drop_caches

echo 3 > /proc/sys/vm/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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: