11

Before jumping in and writing my own code, I want to find out if there is GNU/Linux software that is able to output something similar to QNX's showmem.

For each thread of each process that is running, I would like to see the memory consumption divided into the following categories:

 Process listing (Total, Code, Data, Heap, Stack, Other)
 319488  1024000      24587     167936      24576          0        4103 devc-con-hid (thread 2)
    0          0          0          0       4096          0        4103 devc-con-hid (thread 2)
    0          0          0          0      20480          0        4103 devc-con-hid (thread 1)
    0     102400       8192          0          0          0        4103 devc-con-hid (proc/boot/devc-con-hid)
    0          0      16384          0          0          0        4103 devc-con-hid (proc/boot/libc.so.3)
    0          0          0          0          0  (   36864)       4103 devc-con-hid (/dev/mem)

Is there anything that will make this possible?

  • Looks like most of this info is in /proc/$PID/smaps – Bratchley Jan 21 '15 at 15:01
  • That's right, but I was hoping there is some tool that I can run and automatically outputs the memory information. – Alex Dima Jan 22 '15 at 8:21
  • I'm sure there are memory profilers out there for someone with specific needs. Most people could just periodically save the contents of that proc file. FWIW it sounds like one of valgrind's components has a pretty good profiler. I've never used it but maybe it's a direction for you to go into. – Bratchley Jan 22 '15 at 15:35
6

You can see some information using pmap -x PID - it's divided into kbytes, rss and dirty memory for each library/module/open file/stack of a process:

undefine@uml:~$ pmap -x 13206
13206:   sleep 60
Address           Kbytes     RSS   Dirty Mode  Mapping
0000000000400000      24      20       0 r-x-- sleep
0000000000606000       4       4       4 r---- sleep
0000000000607000       4       4       4 rw--- sleep
000000000063b000     132       8       8 rw---   [ anon ]
00007f6a9847e000    4308      44       0 r---- locale-archive
00007f6a988b3000    1772     376       0 r-x-- libc-2.19.so
00007f6a98a6e000    2048       0       0 ----- libc-2.19.so
00007f6a98c6e000      16      16      16 r---- libc-2.19.so
00007f6a98c72000       8       8       8 rw--- libc-2.19.so
00007f6a98c74000      20      12      12 rw---   [ anon ]
00007f6a98c79000     140     116       0 r-x-- ld-2.19.so
00007f6a98e71000      12      12      12 rw---   [ anon ]
00007f6a98e99000       8       8       8 rw---   [ anon ]
00007f6a98e9b000       4       4       4 r---- ld-2.19.so
00007f6a98e9c000       4       4       4 rw--- ld-2.19.so
00007f6a98e9d000       4       4       4 rw---   [ anon ]
00007fff09fd0000     132      12      12 rw---   [ stack ]
00007fff09ffe000       8       4       0 r-x--   [ anon ]
ffffffffff600000       4       0       0 r-x--   [ anon ]
---------------- ------- ------- ------- 
total kB            8652     656      96

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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