supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* Q: Determine memory consumption
@ 2008-05-06 15:37 Bernhard Graf
  2008-05-06 15:49 ` Ryan Woodrum
  0 siblings, 1 reply; 4+ messages in thread
From: Bernhard Graf @ 2008-05-06 15:37 UTC (permalink / raw)
  To: supervision

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.
-- 
Bernhard Graf


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Q: Determine memory consumption
  2008-05-06 15:37 Q: Determine memory consumption Bernhard Graf
@ 2008-05-06 15:49 ` Ryan Woodrum
  2008-05-07 19:04   ` Bernhard Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Ryan Woodrum @ 2008-05-06 15:49 UTC (permalink / raw)
  To: supervision

[-- Attachment #1: Type: text/plain, Size: 1746 bytes --]

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Q: Determine memory consumption
  2008-05-06 15:49 ` Ryan Woodrum
@ 2008-05-07 19:04   ` Bernhard Graf
  2008-05-08  5:53     ` Ryan Woodrum
  0 siblings, 1 reply; 4+ messages in thread
From: Bernhard Graf @ 2008-05-07 19:04 UTC (permalink / raw)
  To: supervision

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?
-- 
Bernhard Graf


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Q: Determine memory consumption
  2008-05-07 19:04   ` Bernhard Graf
@ 2008-05-08  5:53     ` Ryan Woodrum
  0 siblings, 0 replies; 4+ messages in thread
From: Ryan Woodrum @ 2008-05-08  5:53 UTC (permalink / raw)
  To: supervision

[-- Attachment #1: Type: text/plain, Size: 3227 bytes --]

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-08  5:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-06 15:37 Q: Determine memory consumption Bernhard Graf
2008-05-06 15:49 ` Ryan Woodrum
2008-05-07 19:04   ` Bernhard Graf
2008-05-08  5:53     ` Ryan Woodrum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).