Bug 2383 - `free' command doesn't show amount of cached memory
Summary: `free' command doesn't show amount of cached memory
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.16.x
Hardware: Other Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-10 22:59 UTC by Andrey Batyiev
Modified: 2017-05-24 06:30 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Batyiev 2010-08-10 22:59:18 UTC
Typical busybox `free' command output is:
# free
              total         used         free       shared      buffers
  Mem:        13480         8944         4536            0          968
 Swap:            0            0            0
Total:        13480         8944         4536
# 

which says that almost 2/3 of RAM is used. However:

# cat /proc/meminfo | grep Cached
Cached:             4272 kB
SwapCached:            0 kB
# 

so in fact there is 4Mb in cache, and that means there is 9Mb usable memory (free+cached+buffers). And this means it's only 1/3 of RAM is used. That's confusing.

It would be nice to see amount of cached memory as well as standard line '-/+ buffers/cache:'.
Comment 1 Denys Vlasenko 2010-08-11 22:02:39 UTC
Here is how free from procps-3.2.8 works:

# free -V
procps version 3.2.8

# free
             total       used       free     shared    buffers     cached
Mem:       2056744     568524    1488220          0      24768     233968
-/+ buffers/cache:     309788    1746956
Swap:      4128760          0    4128760

# ls -lR >/dev/null

# free
             total       used       free     shared    buffers     cached
Mem:       2056744     932140    1124604          0     148656     233956
-/+ buffers/cache:     549528    1507216
Swap:      4128760          0    4128760

Semi-cryptic "-/+ buffers/cache:" line means: used and free, corrected for (buffers + cached).


For reference, bbox on the same machine shows:

# busybox free
              total         used         free       shared      buffers
  Mem:      2056744       931140      1125604            0       148672
 Swap:      4128760            0      4128760
Total:      6185504       931140      5254364
Comment 3 craig+busybox 2017-05-24 06:17:47 UTC
It's a little misleading to say this is "fixed". It still doesn't show a "cached" column, and doesn't adjust the 2nd line ("-/+ buffers") by the amount of cache.

I've just been caught out by this myself -- trying to debug memory consumption in an embedded system, and being thrown off by some large file reads using up significant amount of kernel file cache.