`free -m` shows a program on linux use 322M ram, but `top` show it use 58M, why?

1

1

I have a 512M vps box on burst.net, and which has no swap. My os is centos 6.x x64.

When it started, it only used 58M ram.

$ free -m:
             total       used       free     shared    buffers     cached
Mem:           512         58        454          0          0          0
-/+ buffers/cache:         58        454
Swap:            0          0          0

Now I started a java program(which starts by python), then free -m:

$ free -m
             total       used       free     shared    buffers     cached
Mem:           512        380        131          0          0          0
-/+ buffers/cache:        380        131
Swap:            0          0          0

Oh, it used (380-58=322M) ram.

But when I top:

top - 20:37:01 up 67 days,  3:19,  2 users,  load average: 0.08, 0.04, 0.00
Tasks:  20 total,   2 running,  18 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.3%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    524800k total,   388300k used,   136500k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  DATA COMMAND                             
20288 freewind  17   0  936m  48m  11m S  0.0  9.4   0:02.07 799m java                                
20287 freewind  17   0  179m  10m 3404 S  0.0  2.1   0:00.08 7260 python                              
20200 root      15   0 91732 3940 2948 S  0.0  0.8   0:00.03  932 sshd                                
20145 root      15   0 91640 3832 2948 S  0.0  0.7   0:00.02  840 sshd                                
 1474 root      18   0 80296 2312  696 S  0.0  0.4   4:06.86 1684 sendmail                            

I see the java+python only used 48m+10m = 58M ram. Why free -m shows they used 322M? Where is the missing ram?

Freewind

Posted 2012-06-05T16:40:49.847

Reputation: 1 547

Answers

0

In your case, the 'free -m' seems to only be telling you about total RAM usage (probably because you're in a VPS), including buffers and caches which often account for the extra RAM usage not taken by running programs. Have you read the Linux ate my RAM page?

Ankur

Posted 2012-06-05T16:40:49.847

Reputation: 709

-1

top is showing details per each instance or process, but free doesn't.

When you use free you don't know exactly what is running, you just get a summary.

Vic Abreu

Posted 2012-06-05T16:40:49.847

Reputation: 399