Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

So free reports 12318288 total bytes, 11916148 used, and 402140 free (effectively nothing).

Then, top reads like so:

Mem:  12318288k total, 11916596k used,   401692k free,    53756k buffers
Swap: 11894776k total,    40596k used, 11854180k free, 11291256k cached

But the first few processes when sorted by MEM% are:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                   
 1288 postgres  20   0 6361m 6.0g 6.0g S    0 51.3   4:14.82 postgres                                                   
 1285 postgres  20   0 6358m 125m 125m S    0  1.0   0:04.04 postgres                                                   
  490 www-data  20   0  232m  30m 4536 S    0  0.3   0:00.42 apache2                                                    
  493 www-data  20   0  229m  27m 4412 S    0  0.2   0:00.30 apache2                                                    
  499 www-data  20   0  227m  25m 4552 S    0  0.2   0:01.30 apache2                                                    
  500 www-data  20   0  227m  25m 4272 S    0  0.2   0:00.65 apache2                                                    
  491 www-data  20   0  225m  23m 4328 S    0  0.2   0:00.22 apache2                                                    
  583 www-data  20   0  226m  23m 4272 S    0  0.2   0:00.17 apache2                                                    
32603 nobody    20   0  145m  21m  876 S    0  0.2   0:00.46 memcached

Nothing really seems to be taking up memory other than the 6GB allotted to postgres, so why are all 12GB of RAM used?

share|improve this question

4 Answers 4

As KahWee Teng said, it's not a bad thing. It looks like most of your RAM is being used for cache, which is a very good thing. See here for more details:

http://www.linuxatemyram.com/

share|improve this answer

It is not necessarily a bad thing. At least your applications are using them. That said, 6GB is still a lot used. Did you tweak PostgreSQL's configs?

The memory in top does not add up to the one in free by the way.

You may like to read more on memory:

share|improve this answer
    
I've often read it's good to provide postgres about 1/2 your system RAM (shared_buffers option) if it's primarily a DB server, which this is. Disagree? –  Wells Oliver Aug 15 '10 at 0:31

It's because linux doesn't completely free the memory. It caches it to the memory in case that you need it in the future. If you disk if full then the last used memory segment will be release. It's some kind of tweaking. (forums.gentoo.org/viewtopic.php?t=175419) it explains the situation much better than me :>

share|improve this answer

Buffers + Cache .

See this sample "free -m" output :

$ free -m
             total       used       free     shared    buffers     cached
Mem:          1936       1413        522          0         14        500
-/+ buffers/cache:        898       1037
Swap:         2047        259       1788

Total ram is 2Gb, used (1413) == 898 (processes) + 14 (buffers) + 500 (cached)

Linux heavily utilizes RAM to cache/buffer stuff, so is very normal to be using 100% of RAM. Problems arises whenever memory used by processes reaches 100% (ie: you've run out of RAM).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.