[conspire] How much memory each process is taking up

Rick Moen rick at linuxmafia.com
Tue Feb 24 16:08:09 PST 2009


I wrote:

> The next process, "X", is the one where you have to be wary about
> overinterpreting memory-usage stats, because physical RAM on the video
> card is included.  So, the 37MB of RSS reported is vastly overstated.
> How much _real_ RSS, then?  I'm not sure.
> 
> Process "-:0" is somehow related to the "session" of the X server that
> the window manager is talking to. 


I also wrote:

> It's easy to misinterpret the figures for RAM usage of the X server
> process, because reported RAM for _that_ specific process includes
> video memory it uses (so, reported RAM usage is significantly
> overreported).
> 
> That's an approximate way of stating the matter.  Here's a more-exact one:
> http://www.xfree86.org/pipermail/forum/2003-April/003370.html

That mailing list post provides some pointers towards determining the
_true_ physical RAM usage of the X server process.  You fetch
per-process memory figures from the server process's entry in the /proc
filesystem -- which, by the way, is the same place "ps" gets its data
from.

Turns out, I was misremembering about RSS:  RSS is not the figure that's
vastly overreported for X servers.  It's the VSZ that is.

Re-checking the "ps" data about the X process:

rmoen at borgia:~$ ps -eo pid,user,group,%mem,rss,vsz,args | grep X
 2655 root     root      1.5 32060 301784 /usr/bin/X :0 vt7 -nolisten tcp -auth /var/lib/xdm/authdir/authfiles/A:0-ASvsOq


The mailing list post furnishes a nice little shell script for
per-process memory reporting, called "procmem", which I tried out.  (You
need to run it with enough authority to read the /proc/[pid]/* process
data, which in the case of the X server means being the root user.)

borgia:~# /usr/local/bin/procmem 2655
  PID    VSZ DEVMAP LIBMAP  ALLOC    RSS  CMDLINE
 2655 409880 108104  35680 266096  32056  /usr/bin/X :0 vt7 -nolisten tcp -auth  -auth /var/lib/xdm/authdir/authfiles/A:0-ASvsOq
borgia:~# 

As usual, I have Firefox ("iceweasel") open with a half-dozen tabs, a
few xterms running things like centerim and irssi, and Thunderbird
("icedove").  

Notice it says the X process has a virtual size ("VSZ") of 409 MB, which
is clearly _way_ bigger than it could possibly be.  The stat means only that
the X server process has mapped 409 MB of virtual address space:  108 MB
of that ("DEVMAP") is mapped directly to devices, such as the card's
video RAM and other video hardware.   35MB is mapped to X11 shared
libraries ("LIBMAP") and other files mapped into the X server's process
address space.  266 MB is the real, allocated physical memory grabbed
via anonymous mmap() calls.  This RAM isn't necessarily being all used,
but the process got allocated it from the kernel.

However, in any event, the most meaningful figure tends to be the RSS
number, which in this case is _not_ 266 MB, but rather 32 MB, which is
probably a quite accurate picture of real RAM usage (according to my
reading).


Here's a really good mailing list post, also from 2003, about how to
chase down memory usage on Linux:
http://mail.nl.linux.org/linux-mm/2003-03/msg00077.html
I'm pleased to note that my own posts have covered much of the same
territory, but the cited post, by "Jake Dawley-Carr", seems quite 
authoritative.





More information about the conspire mailing list