Unix – Release Memory

This is a very useful command to release the memory without rebooting your system.

You can checked the memory usage first:

$ free
             total       used       free     shared    buffers     cached
Mem:       4055232    3218700     836532          0     449472    1270920
-/+ buffers/cache:    1498308    2556924
Swap:            0          0          0


And I ran vmstat to see more information about my machine.

$ vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 4  0      0 788288 449472 1270872    0    0     3    23    5   21  1  0 99  0  0

It shows more information about the usage.

There are many commands can help you check your machine’s usage; please refer to this nice article: Linux Check Memory Usage.

I tried to kill some processes, but it doesn’t help very much. What I really want is to quickly release the memory, and this command can simply release the memory for you:

$ sudo sync && sudo bash -c 'echo 3 > /proc/sys/vm/drop_caches';

After released the memory:

$ free
             total       used       free     shared    buffers     cached
Mem:       4055232     589272    3465960          0       8644      62764
-/+ buffers/cache:     517864    3537368
Swap:            0          0          0

This is exactly what I searching for.

Related Articles:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s