内存不够清理方法,costdown项目时如果裁剪不下来,也可以参考
2017-08-18 14:32
246 查看
Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches
频繁的文件访问会导致系统的Cache使用量大增
$ free -m
total used free shared buffers cached
Mem: 3955 3926 28 0 55 3459
-/+ buffers/cache: 411 3544
Swap: 5726 0 5726
free内存减少到几十兆,系统运行缓慢
运行sync将dirty的内容写回硬盘
$sync
通过修改proc系统的drop_caches清理free的cache
$echo 3 > /proc/sys/vm/drop_caches
drop_caches的详细文档如下:
Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.
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
As this is a non-destructive operation, and dirty objects are notfreeable,
the user should run "sync" first in order to make sure allcached objects are freed.
This tunable was added in 2.6.16.
修改/etc/sysctl.conf 添加如下选项后就不会内存持续增加
vm.dirty_ratio = 1
vm.dirty_background_ratio=1
vm.dirty_writeback_centisecs=2
vm.dirty_expire_centisecs=3
vm.drop_caches=3
vm.swappiness =100
vm.vfs_cache_pressure=163
vm.overcommit_memory=2
vm.lowmem_reserve_ratio=32 32 8
kern.maxvnodes=3
上面的设置比较粗暴,使cache的作用基本无法发挥。需要根据机器的状况进行适当的调节寻找最佳的折衷
频繁的文件访问会导致系统的Cache使用量大增
$ free -m
total used free shared buffers cached
Mem: 3955 3926 28 0 55 3459
-/+ buffers/cache: 411 3544
Swap: 5726 0 5726
free内存减少到几十兆,系统运行缓慢
运行sync将dirty的内容写回硬盘
$sync
通过修改proc系统的drop_caches清理free的cache
$echo 3 > /proc/sys/vm/drop_caches
drop_caches的详细文档如下:
Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.
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
As this is a non-destructive operation, and dirty objects are notfreeable,
the user should run "sync" first in order to make sure allcached objects are freed.
This tunable was added in 2.6.16.
修改/etc/sysctl.conf 添加如下选项后就不会内存持续增加
vm.dirty_ratio = 1
vm.dirty_background_ratio=1
vm.dirty_writeback_centisecs=2
vm.dirty_expire_centisecs=3
vm.drop_caches=3
vm.swappiness =100
vm.vfs_cache_pressure=163
vm.overcommit_memory=2
vm.lowmem_reserve_ratio=32 32 8
kern.maxvnodes=3
上面的设置比较粗暴,使cache的作用基本无法发挥。需要根据机器的状况进行适当的调节寻找最佳的折衷
相关文章推荐
- Tomcat默认可以使用的内存为128MB,在较大型的应用项目中,这点内存是不够的,需要调大
- 如果你是使用Android studio,如果你的项目里有好多Module是library且电脑配置不是很高,可以参考这篇文章
- Eclipse调整tomcat插件内存方法,以便可以同时部署多个项目
- 菜鸟:自己写了一个轮播代码供分为参考,如果有什么地方你有更好的方法,可以给我留言
- ios影视项目解析 主要为讲block的细节 如果了解了 block的定义等 但是对运用不是很熟悉可以参考本文章
- MyEclipse 清理项目缓存的几大方法
- 自己动手开发jQuery插件全面解析 jquery插件开发方法(这个写的还可以,但不够细致)
- Linux下清理内存和Cache方法
- Linux下清理内存和Cache方法见下文:
- MyEclipse 清理项目缓存的几大方法
- Maven项目遇到OutOfMemoryError可以尝试的方法
- 清理吉日嘎拉走火入魔C#.NET通用权限管理系统组件表数据的脚本方法参考
- C#编译器优化那点事 c# 如果一个对象的值为null,那么它调用扩展方法时为甚么不报错 webAPI 控制器(Controller)太多怎么办? .NET MVC项目设置包含Areas中的页面为默认启动页 (五)Net Core使用静态文件 学习ASP.NET Core Razor 编程系列八——并发处理
- 这是一个从网上找到的类,我只会把它当成方法使用,如果用类不知怎么用,先记下来
- CentOS 7 源码编译mysql5.7.11 ,如果在阿里云内存不足编译失败处理方法
- Tomcat 服务器配置及远程调试和不同web项目session共享方法以及设置TOMCAT的内存
- NET开发初学者,如果你在长沙,可以免费学习项目开发哦!
- grails项目编译时,如果报错:java.lang.NoClassDefFoundError: org/apache/commons/cli/Options的解决方法
- Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches
- 在做app应用的时候,需要将数据提交到服务器去存储,那么方法可以参考如下