0

Below is the output of free in Ubuntu:

$ free
             total       used       free     shared    buffers     cached
Mem:       8173180    8013092     160088          0    1076276    3091136
-/+ buffers/cache:    3845680    4327500
Swap:     11719380        312   11719068

Total physical memory is 8 gb. Total used memory is close to that, but the total memory used by buffer cache is half that, approximately 4 gb. Hardly any memory is being used as swap.

Now the buffer cache is derived because we have had read/writes to disk and then after first time, the applications are loaded in memory until no longer needed to speed up read/writes. So the total of read/writes for disk buffering is the 4 gb.

Ok, but what kind of processes are using the other 4 gigs of physical memory (excluding buffer cache)? How can I determine that?

  • You can see how much memory each process is using either in gnome-system-monitor or ps ax -o pid,vsize,args | sort -nk2 at the command line – Bratchley May 6 '14 at 17:27
  • @JoelDavis I would like to know what that other 4 gb of memory is used for. It's not used for buffer cache. It's not used for swap. What is that other 4 gigs of memory being used for? – JohnMerlino May 6 '14 at 17:30
  • @JohnMerlino it's the stack and heap memory of your running programs. – derobert May 6 '14 at 18:03
  • @JoelDavis or just top! – derobert May 6 '14 at 18:04
  • pft, top's for quitters. – Bratchley May 6 '14 at 19:42
2

The remaining memory is being used for the heap and stack of the various programs running on your system. As Joel Davis said in his comment, you can use gnome-system-monitor or ps (though you want rss instead of vsize) to see which programs are using it. You can also use the top command-line tool, which sorts by CPU usage by default. Type M and it'll switch to sorting by memory usage.

Also, I'd like to correct a misunderstanding: Swap does not use memory. That 312 doesn't mean that 312KB of RAM is used for swap. It actually means 312 KB of swap is used in place of RAM. If your machine runs out of RAM, it'll start writing the contents of memory out to disk ("paging") to free up that RAM. That swap number is telling you how much RAM has been written to disk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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