Interpreting top, vmstat, and company

Oliver Fromme olli at lurza.secnetix.de
Wed Aug 13 16:40:01 UTC 2008


Christopher Cowart wrote:
 > What is the difference between the SIZE and RES fields of top?

These are the same as the "SIZ" and "RSS" columns in ps(1).

The former is the total virtual size of the process, i.e.
the sum of all pages mapped into the process.  The latter
is the part that is currently resident, i.e. in physical
RAM.  Therefore you have always SIZ >= RSS.  If RSS is 0,
it usually means that the process is completely swapped
to disk.

Note that *both* numbers include pages shared with other
processes, such as text pages (that's executable code, not
ASCII text) from binaries and libraries, and shared memory.

 > How does this work with a threaded program like apache?

Multiple threads within the same process always share the
memory.  So, as far as the memory consumption is concerned,
it doesn't matter at all if a process is threaded or not,
and how many threads it contains.

 > Some sample top output on this host:
 > 
 > Mem: 131M Active, 3754M Inact, 425M Wired, 177M Cache, 214M Buf, 3422M Free
 > Swap: 16G Total, 24K Used, 16G Free
 > [...]
 >   PID USERNAME    THR PRI NICE   SIZE    RES STATE  C   TIME   WCPU COMMAND
 > 32361 root          1  96    0   106M 16604K select 2   0:02  0.00% httpd
 > 50687 www           1  20    0   106M 17196K lockf  0   0:01  0.00% httpd
 > 
 > I'm having a hard time accounting for the 3.8GB of inactive memory

That looks like you have really plenty of RAM.
Basically those numbers mean this:

425 MB of RAM is wired memory.  Most of this (maybe even
all) belongs to the kernel.  "Wired" means memory pages
that are fixed in physical RAM.  The kernel cannot be
paged to disk (at least not in FreeBSD), so kernel memory
is usually wired.

131 MB of RAM is actively being used by processes.

Everything else is just different kinds of cache.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"Software gets slower faster than hardware gets faster."
        -- Niklaus Wirth


More information about the freebsd-questions mailing list