http://www.perlmonks.org?node_id=712647


in reply to [OT]What is "buffers" and "cached" memory in Linux system box?

What should I think of the "buffers" and "cached" memory? should I think they are part of free memory?

This is a verbatim copy of what I wrote down when I had this same question:

total used free shared buffers cac +hed Mem: 1034332 983572 50760 0 149028 530 +132 -/+ buffers/cache: 304412 729920 Swap: 131064 9856 121208 Mem: A B C D E + F -/+ buffers/cache: G H G+H = A E+F+G = B ## probably D+E+F+G C+E+F = H ## probably C+D+E+F

--
David Serrano

  • Comment on Re: [OT]What is "buffers" and "cached" memory in Linux system box?
  • Download Code

Replies are listed 'Best First'.
Re^2: [OT]What is "buffers" and "cached" memory in Linux system box?
by sunshine_august (Scribe) on Sep 20, 2008 at 03:33 UTC
    I try to rearrange the expression to make it more clear:
    A = B + C = G + H G = B - E - F H = C + E + F
    It seems that:

    Mem: 1034332 983572 50760 0 149028 530132
    shows "buffers" and "cached" as part of "used" memory.

    But -/+ buffers/cache: 304412 729920
    shows "buffers" and "cached" as part of "free" memory

    The -/+ buffers/cache line shows how much memory is used and free from the perspective of the applications.
    --- from http://gentoo-wiki.com/FAQ_Linux_Memory_Management#The_difference_between_buffers_and_cache

    And I do a test on my box, it shows that when the "free" memory is going to be exhausted, the kernel will take back all the "buffers" memory, but still left some "cached"memory. Following is the output by "free -m -s 1" when I increasingly created threads to consume the memory:

    total used free shared buffers cac +hed Mem: 7973 68 7904 0 8 + 27 -/+ buffers/cache: 33 7939 Swap: 2047 0 2047 total used free shared buffers cac +hed Mem: 7973 106 7866 0 8 + 27 -/+ buffers/cache: 71 7902 Swap: 2047 0 2047