RE: Minimo's RSS, etc

"Dan Post" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.small-devices
Message-ID <[email protected]>
On Thu, 20 May 2004 09:35:14 -0700, steve clark wrote
> Do you have a reference for how to interpret the contents of the
> /proc/X/maps file?  I'm working with the mozilla code on a small footprint
> device, but I haven't found good documentation on how to interpret 
> this data in order to understand real memory usage.  We're using a 
> derivative of Redhat Linux 7.3, if that makes any difference.

man proc
linux-x.y.z/Documentation/filesystems/proc.txt

I've been mosty using the ARM-Linux distribution (from www.arm.linux.org.uk),
specifically 2.4.19-rmk7-pxa2 for the most part, but it should be the same as
RedHat.

I forgot, the typical /proc/X/maps file DOESN'T include RSS size for
individual mappings (which is the most useful piece of info IMHO).  I have a
simple patch that adds per-mapping RSS reporting--I'll put it up on my website
some time today or tomorrow.

The idea is once you have the RSS patch in place, you can examine how much
code is RSS, how much data is RSS, and how much BSS is RSS, etc.

The total mapping size tells you what the range of the memory map is.  If an
entry is marked r-xp and is backed by a file (executable, shared library, data
file...), then that is the code segment.  Then the RSS tells you how much is
in the pagecache (because it's an mmap()'d file).

If it's backed by a file but is rwxp or rw-p (can't remember if it's
necessarily either), then that's the process's data segment.  The RSS tells
you what % of pages have been touched or read (I think it can dump pages that
have only been read, but not written to... I will need to look at this closer,
but it's not that important to me right now).

If it's rw-p or rwxp (I've seen ---p but don't know what that means yet), and
not backed by a file (i.e. an anonymous mapping), then that is a BSS segment
or your stack.  The RSS in that case tells you how much is resident (of
course).  Since the pages are lazily allocated, your BSS size may be really
huge, but since your malloc() routine hasn't touched it all, your real memory
usage (RSS) will be much lower.  This is partially dependent on how fragmented
your memory gets.

There are, of course, other permutations, but these are the main ones I've
seen and am concerned with.

I'll send that patch out soon.

Cheers,
Dan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.