查看系统内存占用

2016-12-12  本文已影响0人  沧行

free命令(可以使用free -m,表示以MB作为单位):

屏幕快照 2016-12-05 上午10.18.06.png

系统真实使用的内存是:used-buffers-cached

buffers和cached对于应用程序来说是可用的,因为这两种内存是为了提升文件读取性能而设置的,当应用程序需要内存时,这两种内存能很快被回收。

通过top命令查看进程内存占用:
top -d 10 -p $pid

屏幕快照 2016-12-05 上午11.56.43.png

每隔十秒刷新一次,%MEM为进程内存占用百分比。

cached用于缓存打开的文件,频繁文件访问会导致系统cached增大,可以通过linux命令释放掉这块儿内存,
首先运行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:

上一篇下一篇

猜你喜欢

热点阅读