On Wednesday 07 May 2008 12:04:56 pm Bernhard Graf wrote: > On Tuesday 06 Mai 2008, Ryan Woodrum wrote: > > On Tuesday 06 May 2008 08:37:36 am Bernhard Graf wrote: > > > With softlimit (and ulimit) one can set several memory limits, most > > > interesting data and stack segment. > > > > > > How do I determine the actual memory consumption for data and stack > > > of a process? > > > With tools like ps and top I only get code + data + stack summed > > > up. > > > > Something like pmap? > > > > rwoodrum@frums:~$ pmap -d 888 > > 888: /bin/bash > > Address Kbytes Mode Offset Device Mapping > > 08048000 664 r-x-- 0000000000000000 008:00001 bash > > 080ee000 20 rw--- 00000000000a6000 008:00001 bash > > 080f3000 2572 rw--- 00000000080f3000 000:00000 [ anon ] > > b7c67000 28 r--s- 0000000000000000 008:00005 gconv-modules.cache > > b7c6e000 212 r--s- 0000000000000000 008:00006 passwd > > b7ca3000 1256 r---- 0000000000000000 008:00005 locale-archive > > b7ddd000 4 rw--- 00000000b7ddd000 000:00000 [ anon ] > > b7dde000 1312 r-x-- 0000000000000000 008:00001 libc-2.7.so > > b7f26000 4 r---- 0000000000148000 008:00001 libc-2.7.so > > b7f27000 8 rw--- 0000000000149000 008:00001 libc-2.7.so > > b7f29000 16 rw--- 00000000b7f29000 000:00000 [ anon ] > > b7f2d000 8 r-x-- 0000000000000000 008:00001 libdl-2.7.so > > b7f2f000 8 rw--- 0000000000001000 008:00001 libdl-2.7.so > > b7f31000 184 r-x-- 0000000000000000 008:00001 libncurses.so.5.6 > > b7f5f000 12 rw--- 000000000002d000 008:00001 libncurses.so.5.6 > > b7f77000 8 rw--- 00000000b7f77000 000:00000 [ anon ] > > b7f79000 104 r-x-- 0000000000000000 008:00001 ld-2.7.so > > b7f93000 8 rw--- 0000000000019000 008:00001 ld-2.7.so > > bfd11000 84 rw--- 00000000bffeb000 000:00000 [ stack ] > > ffffe000 4 r-x-- 0000000000000000 000:00000 [ anon ] > > mapped: 6516K writeable/private: 2740K shared: 240K > > Which one is the data section? Exploring some other options to answer this question looks like you could use something like `size` or, if you have an object file, `objdump`. Check out: http://dirac.org/linux/gdb/02a-Memory_Layout_And_The_Stack.php Here's a sample run on /bin/ls: rwoodrum@slard:~$ size /bin/ls text data bss dec hex filename 88264 908 1132 90304 160c0 /bin/ls I'm not learned enough off the top of my head to know how this changes (if it does indeed) once a process is running. I would think that it could if it maps in other stuff at runtime. However, with regard to the pmap output, you can possibly make some educated guesses based on the modes of the segments of memory as well as their location. Text pages, for example, are not writable as this could obviously lead to Bad Things. The stack segment is also at the high address and grows downward whereas the text and data segments are at the low end of the address space and grow upward. Just thinking randomly, it might also be possible to force a core and examine it for the same answers. Hope this helps! -ryan woodrum rwoodrum@avvo.com