[PLUG] Memory usage in top with multiple processes

Elliott Mitchell ehem at m5p.com
Sun Dec 11 22:17:32 UTC 2005


>From: Matt Alexander <lowbassman at gmail.com>
> Here's something I've always wondered...  When I run "top" I may see 
> quite a few of the same process name listed.  Each entry has the exact 
> same values from SIZE, RSS, and SHARE.  However, multiplying the number 
> of entries by the RSS value would far exceed the amount of RAM + swap on 
> the box.  So...  what's really going on?

As Paul mentioned, if they're all identical than most likely they're
either threads or forks which are all sharing the same memory.

SHARE may include files mmap()ed by multiple processes as well as SysV
shared memory, and the former can be written to disk rather than swap.
I'm unsure whether top will include memory sharing caused by threads and
forks in this number. Crucially though, this will appear in multiple
processes (worse some of those might have differing portions mapped, and
so even if the number differs for two processes they could be sharing).
This is why top gives you a separate number for shared memory.

RSS is the portion of the process's address space that is actively
mapped (been used "recently"), not something excluding SIZE. Therefore
you shouldn't be including this in your total.

SIZE can include a number of extras. Notably any "file" that has been
mmap()ed. Though mmap()ed files may take up memory, they will never take
swap space because they're tied to an actual file on disk (FreeBSD though
may cache these in swap though). Of greater note is that X will mmap()
the framebuffer, and that will be included in SIZE. I suspect nVIDIA's
driver may also give framebuffer access to programs if they can access
the appropriate device.


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         EHeM at gremlin.m5p.com PGP 8881EF59         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
    \___\_|_/82 04 A1 3C C7 B1 37 2A*E3 6E 84 DA 97 4C 40 E6\_|_/___/





More information about the PLUG mailing list