1

When I cat /proc/meminfo I see:

MemTotal: 1048576 kB MemFree: 11136 kB Buffers: 0 kB Cached: 0 kB SwapCached: 0 kB Active: 0 kB Inactive: 0 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 1048576 kB LowFree: 11136 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 88 kB Writeback: 0 kB AnonPages: 0 kB Mapped: 0 kB Slab: 0 kB PageTables: 0 kB NFS_Unstable: 0 kB Bounce: 0 kB CommitLimit: 0 kB Committed_AS: 0 kB VmallocTotal: 0 kB VmallocUsed: 0 kB VmallocChunk: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 Hugepagesize: 2048 kB 

when I do top and sort by memory I see:

%MEM TIME+ COMMAND %22.9 0:44.11 java % 0.1 0:04.57 init % 2.9 0:02.52 /usr/local/cpan % 0.3 0:00.50 sshd % 1.5 0:00.14 mysqld % 0.5 0:00.13 leechprotect % 0.1 0:00.12 bash % 0.4 0:00.11 httpd % 0.3 0:00.07 queueprocd - wa % 0.4 0:00.06 tailwatchd % 0.8 0:00.02 cpsrvd-ssl % 0.1 0:00.02 top % 0.1 0:00.01 syslogd % 0.4 0:00.01 named % 0.1 0:00.00 udevd % 0.0 0:00.00 klogd % 0.0 0:00.00 courierlogger % 0.1 0:00.00 authdaemond % 0.0 0:00.00 authdaemond % 0.0 0:00.00 authdaemond % 0.1 0:00.00 sshd % 0.1 0:00.00 xinetd % 0.1 0:00.00 mysqld_safe % 0.0 0:00.00 courierlogger % 0.1 0:00.00 couriertcpd % 0.1 0:00.00 exim % 0.1 0:00.00 pure-ftpd % 0.1 0:00.00 pure-authd % 0.1 0:00.00 crond % 0.0 0:00.00 atd % 0.2 0:00.00 cPhulkd - proce % 2.8 0:00.00 spamd child % 0.8 0:00.00 cpdavd - accept % 0.4 0:00.00 httpd % 0.4 0:00.00 httpd % 0.4 0:00.00 httpd % 0.4 0:00.00 httpd % 0.4 0:00.00 httpd % 0.2 0:00.00 cpanellogd - sl % 0.1 0:00.00 saslauthd % 0.0 0:00.00 saslauthd % 0.1 0:00.00 ssh-agent 

Why does top show ~38% used when in reality it used 900mb out of 1000mb? How i know how much memory each process uses?

1
  • If I search for "memory usage" on this site I get 224 results. Don't you think you should have searched for the answer before you ask that question one more time? Commented May 22, 2013 at 2:18

1 Answer 1

1

Memory usage can be quite confusing when first starting out with Linux. In general Linux takes the perspective that all of RAM should be put to use instead of conserving it just for processes.

So RAM is used for both processes and as a cache for files as they get loaded from the hard drive. You can see this better with the free command:

# free output in MBs $ free -m total used free shared buffers cached Mem: 7800 6724 1075 0 397 1952 -/+ buffers/cache: 4374 3425 Swap: 5823 27 5796 

This is showing you that I have ~7.8GB of RAM, of which ~6.7GB is in use, leaving ~1GB free, in this line:

Mem: 7800 6724 1075 0 397 1952 

The next line is the one that enlightens you to what's actually going on:

-/+ buffers/cache: 4374 3425 

This line shows that of the ~6.7GB being reported as "used" by the first line, if you take the buffers and cache out of the mix we're really only using ~4.4GB. So in actuality I really have ~3.4GB of RAM free.

The buffers and cache are files that have been loaded by the Kernel from the HDD to RAM to improve performance.

excerpt from linfo.org

The second line of data, which begins with -/+ buffers/cache, shows the amount of physical memory currently devoted to system buffer cache. This is particularly meaningful with regard to application programs, as all data accessed from files on the system that are performed through the use of read() and write() system calls pass through this cache. This cache can greatly speed up access to data by reducing or eliminating the need to read from or write to the HDD or other disk.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.