为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

释放内存的方法

2018-02-19 2页 doc 13KB 18阅读

用户头像

is_003124

暂无简介

举报
释放内存的方法释放内存的方法 这种释放方法是相当地痛快,而且如果真是non-destructive operation的话那就太好了, jvm 的内存占用一下子减少了接近300m. #sync 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 ...
释放内存的方法
释放内存的方法 这种释放方法是相当地痛快,而且如果真是non-destructive operation的话那就太好了, jvm 的内存占用一下子减少了接近300m. #sync 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. 再说说 free 命令 # free -m total used free shared buffers cached Mem: 497 438 59 0 20 325 -/+ buffers/cache: 92 404 Swap: 511 22 489 其中: 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 下面包含一个自动释放内存的脚本,网上学习的, 加入了crondtab计划任务了 # vim /root/shTools/freemem.sh #!/bin/bash used=`free -m | awk 'NR==2' | awk '{print $3}'` free=`free -m | awk 'NR==2' | awk '{print $4}'` echo "===========================" >> /var/log/mem.log date >> /var/log/mem.log echo "Memory usage | [Use:${used}MB][Free:${free}MB]" >> /var/log/mem.log if [ $free -le 100 ] ; then sync && echo 1 > /proc/sys/vm/drop_caches sync && echo 2 > /proc/sys/vm/drop_caches sync && echo 3 > /proc/sys/vm/drop_caches echo "OK" >> /var/log/mem.log else echo "Not required" >> /var/log/mem.log 将脚本添加到crond任务,定时执行。 # echo "*/30 * * * * root /root/shTools/freemem.sh" >> /etc/crondtab
/
本文档为【释放内存的方法】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索