2

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?

0

4 Answers 4

3

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/

1

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:

1
  • 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? Aug 15, 2010 at 0:31
0

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 :>

0

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .