Author |
Topic: Linux Memory Management |
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
Linux Memory Management |
You can use free to find out all memory allocated to your Linux box and how many memory your applications can use.
# free -m
total used free shared buffers cached
Mem: 595 382 212 0 132 190
-/+ buffers/cache: 59 535
Swap: 0 0 0
To explain the output, let's consider the general case:
# free -m
total used free shared buffers cached
Mem: A B C 0 D E
-/+ buffers/cache: F G
Swap: 0 0 0
Here comes the facts: A -- the total memory allocated to your Linux box. D+E -- buffers/cached memory gracefully occupied by system in case there are availabe. G(=C+D+E) -- free memory your apps can use. F(=B-D-E or =A-G) -- used memory by your apps.
|
|
|
|
|
|
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
How many total memory is allocated to my Linux box? |
That is A=595 (MB).
# free -m | grep 'Mem' | tr -s ' ' | cut -d ' ' -f 2
|
|
|
|
|
|
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
How many more memory my applications can still use? |
That is G=535 (MB).
# free -m | grep 'buffers/cache' | tr -s ' ' | cut -d ' ' -f 4
|
|
|
|
|
|
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
How many memory my applications have used? |
That is F=59 (MB).
# free -m | grep 'buffers/cache' | tr -s ' ' | cut -d ' ' -f 3
|
|
|
|
|
|
|
Linux member offline |
|
posts: |
120 |
joined: |
01/24/2011 |
from: |
San Jose, CA |
|
|
|
|
|
How to force the buffers/cached memory to release? |
# echo 3 > /proc/sys/vm/drop_caches
Run free again:
# free -m
total used free shared buffers cached
Mem: 595 52 542 0 0 8
-/+ buffers/cache: 43 551
Swap: 0 0 0
|
|
|
|
|
|
|