Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Surprisingly, comprehensive documentation for /procfs is hard to find. For my specific question, I am looking at: cat /proc/1/statm (let's use pid=1 because it seems to be always there). I just ran this and got a result:

9370 954 341 210 0 727 0
  1. Which one of these is resident memory?
  2. What is it measured in?
  3. How can I convert it to Megabytes?
share|improve this question
    
Well, I found something useful here: kernel.org/doc/Documentation/filesystems/proc.txt and the memory is computed in pages whereas one can tell what the page size is by running $ getconf PAGESIZE or $ getconf PAGE_SIZE which should equal 4096 on a typical Linux distro. I am still not sure what those numbers refer to. I searched for "1-4" without the quotes within the linked document to find the explanation. Also, in python one can do: import resource; print resource.getpagesize(). –  Leonid Apr 16 '13 at 23:04
    
    
Oh, and this bit tells me that resident memory is the second number. lindevdoc.org/wiki//proc/pid/statm I wish this info was all in one place though. –  Leonid Apr 16 '13 at 23:29
add comment

1 Answer

The documentation is in Documentation/filesystems/proc.txt in the kernel source. Many distributions make it available through a package (e.g. linux-doc under Ubuntu, installing files under /usr/share/doc/linux-doc).

Here's the description of the statm fields from the documentation:

Field    Content
size     total program size (pages)     (same as VmSize in status)
resident size of memory portions (pages)    (same as VmRSS in status)
shared   number of pages that are shared    (i.e. backed by a file)
trs      number of pages that are 'code'    (not including libs; broken, includes data segment)
lrs      number of pages of library     (always 0 on 2.6)
drs      number of pages of data/stack      (including libs; broken, includes library text)
dt       number of dirty pages          (always 0 on 2.6)

This process has 954 pages in RAM. A page is 4kB on your system (it can be other values on exotic architectures or configurations; getconf PAGESIZE would confirm it). So that's a bit under 4MB.

The documentation isn't exhaustive. If you can't find what you're looking for, try searching on the Linux Weekly News or elsewhere on the web. If you still can't find the answer, use the source.

share|improve this answer
1  
There is also a proc(5) manpage on my debian system. –  jordanm Apr 17 '13 at 0:30
    
Ah, it is man 5 proc, not man 5 procfs. I have that on FC16 as well. –  Leonid Apr 18 '13 at 17:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.