hieuhtr / Blog

Don’t be lazy. Don’t make excuses. No one cares. Work fucking harder.
Other
6 stars 2 forks source link

Clean buffers and cached on linux #47

Open hieuhtr opened 7 years ago

hieuhtr commented 7 years ago

Need root permission

# clean buffer and cached
root@appv2-1:~# free -m && sync && echo 3 > /proc/sys/vm/drop_caches && free -m

# step by step
root@appv2-1:~# free -m
             total       used       free     shared    buffers     cached
Mem:          3951       3260        691          0         46        121
-/+ buffers/cache:       3092        859
Swap:         4095          0       4095
root@appv2-1:~# sync
root@appv2-1:~# echo 3 > /proc/sys/vm/drop_caches
root@appv2-1:~# free -m
             total       used       free     shared    buffers     cached
Mem:          3951       3065        886          0          2         22
-/+ buffers/cache:       3040        911
Swap:         4095          0       4095

Before: buffers = 46 mb, cached = 121 mb After: buffers = 2 mb, cached = 22 mb