歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> Linux釋放內存

Linux釋放內存

日期:2017/3/3 11:55:35   编辑:Linux技術
Linux釋放內存
在Linux上我們通常可以使用下面的命令來查看系統內存使用情況
[code]$ free -m
$ cat /proc/meminfo

通常我們可以根據具體情況使用下面的命令來釋放內存(需要root權限來執行)
Freeing Up the Page Cache
[code]# echo 1 > /proc/sys/vm/drop_caches
# sync

Freeing Up the Dentries and Inodes
[code]# echo 2 > /proc/sys/vm/drop_caches
# sync

Freeing Up the Page Cache, Dentries and Inodes
[code]# echo 3 > /proc/sys/vm/drop_caches
# sync

也可以使用下面一條長命令
[code]sudo su -c 'free -m && sync && echo 3 > /proc/sys/vm/drop_caches && sync && free -m'

在我的虛擬機上運行結果如下
[code]              total        used        free      shared  buff/cache   available
Mem:           2848        2094          82          29         671         471
Swap:          2047         914        1133

              total        used        free      shared  buff/cache   available
Mem:           2848        2081         294          29         471         491
Swap:          2047         914        1133

轉載請以鏈接形式標明本文地址
本文地址:/content/10920787.html
Copyright © Linux教程網 All Rights Reserved