Question about 'top' values on memory usage

Dan Nelson dnelson at allantgroup.com
Sun Oct 14 13:34:23 PDT 2007


In the last episode (Oct 14), Artem Kuchin said:
> Maybe someone with deeper knowledge of the internals of FreeBSD can
> clean up something for me (any for many others)^
> 
> Here are lines from my top:
> 
>  PID USERNAME    THR PRI NICE   SIZE    RES STATE  C   TIME   WCPU COMMAND
> 9258 hordelo_ru    1   4    0 40992K  4260K accept 0   0:00  0.00% httpd
> 9257 hordelo_ru    1  44    0 40992K  4296K select 1   0:00  0.00% httpd
> 9259 hordelo_ru    1   4    0 40992K  4292K select 1   0:00  0.00% httpd
> 
> As you see, 'size' is the same for all processes, while RES varies.
> 
> As i understand, the real memory taken by a process is RES and SIZE
> include a bunch of shares .so libs, so, if more httpd's started each
> will take only about 4300K more, so, 100 https will take 430000K to
> run, right?

The memory used by a process is SIZE.  RES is the amount of that memory
that's in memory.  The rest would either be still on disk (in the form
of executable or mmaped pages that haven't been accessed), in swap, or
prezeroed pages that haven't been accessed yet (large blocks of
malloc()'ed memory for example).  Processes forked from the same parent
can share the same pages until one process writes to one (a copy is
then made so the other processes still see the right data).  Chances
are that those three httpd processes are sharing 99% of their pages.  I
don't know of any easy way of determing exactly how much non-shared
memory a particular process has.
 
-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-stable mailing list