Linux释放内存

默北 Linux Linux命令Linux释放内存已关闭评论20,6842字数 414阅读1分22秒阅读模式

Linux下频繁存取文件时,物理内存可能会被耗尽,当程序结束后,内存不会释放,而是一直作为cache。

Linux缓存有dentry,buffer cache,page cache。Dentry用来加速文件路径名到inode的转换;buffer cache加速磁盘块的读写;page cache加速inode的读写。缩短IO调用时间。文章源自运维生存时间-https://www.ttlsa.com/linux/release-the-memory-linux/

释放内存方法:
1.释放page cahce文章源自运维生存时间-https://www.ttlsa.com/linux/release-the-memory-linux/

# echo 1 > /proc/sys/vm/drop_cache

2.释放dentry和inode文章源自运维生存时间-https://www.ttlsa.com/linux/release-the-memory-linux/

# echo 2 > /proc/sys/vm/drop_cache

3.释放page cache,dentry,inode文章源自运维生存时间-https://www.ttlsa.com/linux/release-the-memory-linux/

# echo 3 > /proc/sys/vm/drop_cache

在释放内存前,最好先允许sync,强制将系统正在处理的page cahce,dentry,inode写入磁盘。文章源自运维生存时间-https://www.ttlsa.com/linux/release-the-memory-linux/

如需转载请注明出处: https://www.ttlsa.com/html/3020.html文章源自运维生存时间-https://www.ttlsa.com/linux/release-the-memory-linux/ 文章源自运维生存时间-https://www.ttlsa.com/linux/release-the-memory-linux/

weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
默北
  • 本文由 发表于 14/09/2013 22:31:06
  • 转载请务必保留本文链接:https://www.ttlsa.com/linux/release-the-memory-linux/