3

On Ubuntu 12.04, I have several apache2 processes running (the 1130 parent and the children it spawned), and as you can see, they have around 300-400 mb of virtual memory and 10 mb of resident memory:

$ ps aux | grep apache2
root      1130  0.0  0.1 149080 10600 ?        Ss   Jul11   0:03 /usr/sbin/apache2 -k start
www-data 23440  0.0  0.3 163660 24096 ?        S    10:46   0:01 /usr/sbin/apache2 -k start
www-data 27349  0.0  0.3 163380 23768 ?        S    13:16   0:01 /usr/sbin/apache2 -k start
www-data 27949  0.0  0.3 163912 24300 ?        S    13:36   0:01 /usr/sbin/apache2 -k start
www-data 28568  0.0  0.3 161496 22852 ?        S    14:15   0:00 /usr/sbin/apache2 -k start
www-data 28622  0.0  0.3 163656 23924 ?        S    14:18   0:00 /usr/sbin/apache2 -k start
www-data 28874  0.0  0.3 163600 23636 ?        S    14:33   0:00 /usr/sbin/apache2 -k start
www-data 28881  0.0  0.1 149368  7840 ?        S    14:33   0:00 /usr/sbin/apache2 -k start
www-data 28884  0.0  0.2 152856 12768 ?        S    14:33   0:00 /usr/sbin/apache2 -k start
www-data 29459  0.0  0.1 149368  7788 ?        S    15:07   0:00 /usr/sbin/apache2 -k start
www-data 29531  0.0  0.1 149184  7256 ?        S    15:10   0:00 /usr/sbin/apache2 -k start
1000     29543  0.0  0.0   8112   900 pts/0    S+   15:11   0:00 grep apache2

The problem with using virtual memory and resident memory as a measure of memory usage is that many of these processes may be using shared libraries and therefore the individual memory usage of these processes may not be accurate. So pmap is often used instead. pmap gives the the "writeable/private" total of a process, which can be considered the incremental cost of this process, factoring out the shared libraries.

So I take a specific process, let's say, 23440 and try to find out its memory usage:

$ pmap -d 23440
23440:   /usr/sbin/apache2 -k start
Address           Kbytes Mode  Offset           Device    Mapping
mapped: 0K    writeable/private: 0K    shared: 0K

Ok so that didn't tell me anything. What is going on?

1 Answer 1

2

You need to be root or the user that the process is owned by to use that command. Try this instead:

$ sudo pmap -d 23440

For example

$ sudo pmap -d 1457
1457:   /usr/sbin/httpd
Address           Kbytes Mode  Offset           Device    Mapping
00007ff9f23bf000      76 r-x-- 0000000000000000 0fd:00000 zip.so
00007ff9f23d2000    2044 ----- 0000000000013000 0fd:00000 zip.so
00007ff9f25d1000       8 rw--- 0000000000012000 0fd:00000 zip.so
00007ff9f25d3000      12 r-x-- 0000000000000000 0fd:00000 libgpg-error.so.0.5.0
00007ff9f25d6000    2044 ----- 0000000000003000 0fd:00000 libgpg-error.so.0.5.0
00007ff9f27d5000       4 rw--- 0000000000002000 0fd:00000 libgpg-error.so.0.5.0
...
...
00007fff70db1000      84 rw--- 0000000000000000 000:00000   [ stack ]
00007fff70dff000       4 r-x-- 0000000000000000 000:00000   [ anon ]
ffffffffff600000       4 r-x-- 0000000000000000 000:00000   [ anon ]
mapped: 290336K    writeable/private: 6288K    shared: 580K

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .