0

I m developping a c application running on linux as daemon.

My application is loading 3 shared libraries(*.so). And for some times it execute a shell scripts.

Should I take on account the script shell and the 3 shared libraries in the calculation of my footprint?

How I can find out the memory footprint of my application?

EDIT

Is it possible to extract the footprint from the /proc/$pid/maps?

root@Linux:~# cat /proc/25998/maps
00400000-00412000 r-xp 00000000 1f:00 2823       /usr/sbin/mydaemond
00422000-00423000 rw-p 00012000 1f:00 2823       /usr/sbin/mydaemond
005a9000-005db000 rwxp 00000000 00:00 0          [heap]
76bd3000-76bd4000 ---p 00000000 00:00 0
76bd4000-76dd3000 rw-p 00000000 00:00 0          [stack:26009]
76dd3000-76dd4000 ---p 00000000 00:00 0
76dd4000-76fd3000 rw-p 00000000 00:00 0          [stack:26008]
76fd3000-76fd4000 ---p 00000000 00:00 0
76fd4000-771d3000 rw-p 00000000 00:00 0          [stack:26007]
771d3000-771d4000 ---p 00000000 00:00 0
771d4000-773d3000 rw-p 00000000 00:00 0          [stack:26006]
773d3000-773d4000 ---p 00000000 00:00 0
773d4000-775d3000 rw-p 00000000 00:00 0          [stack:26005]
775d3000-775d6000 r-xp 00000000 1f:00 799        /lib/libdl-0.9.33.2.so
775d6000-775e5000 ---p 00000000 00:00 0
775e5000-775e6000 r--p 00002000 1f:00 799        /lib/libdl-0.9.33.2.so
775e6000-775e7000 rw-p 00003000 1f:00 799        /lib/libdl-0.9.33.2.so
775e7000-775f9000 r-xp 00000000 1f:00 1436       /usr/lib/libz.so.1.2.7
775f9000-77608000 ---p 00000000 00:00 0
77608000-77609000 rw-p 00011000 1f:00 1436       /usr/lib/libz.so.1.2.7
77609000-7764e000 r-xp 00000000 1f:00 1402       /usr/lib/libssl.so.1.0.0
7764e000-7765e000 ---p 00000000 00:00 0
7765e000-77662000 rw-p 00045000 1f:00 1402       /usr/lib/libssl.so.1.0.0
77662000-77781000 r-xp 00000000 1f:00 1253       /usr/lib/libcrypto.so.1.0.0
77781000-77790000 ---p 00000000 00:00 0
77790000-777a1000 rw-p 0011e000 1f:00 1253       /usr/lib/libcrypto.so.1.0.0
777a1000-777a2000 rw-p 00000000 00:00 0
777a2000-77806000 r-xp 00000000 1f:00 808        /lib/libuClibc-0.9.33.2.so
77806000-77815000 ---p 00000000 00:00 0
77815000-77816000 r--p 00063000 1f:00 808        /lib/libuClibc-0.9.33.2.so
77816000-77817000 rw-p 00064000 1f:00 808        /lib/libuClibc-0.9.33.2.so
77817000-7781d000 rw-p 00000000 00:00 0
7781d000-77830000 r-xp 00000000 1f:00 801        /lib/libgcc_s.so.1
77830000-77840000 ---p 00000000 00:00 0
77840000-77841000 rw-p 00013000 1f:00 801        /lib/libgcc_s.so.1
77841000-77849000 r-xp 00000000 1f:00 1329       /usr/lib/libjson-c.so.2.0.1
77849000-77858000 ---p 00000000 00:00 0
77858000-77859000 rw-p 00007000 1f:00 1329       /usr/lib/libjson-c.so.2.0.1
77859000-7785a000 r-xp 00000000 1f:00 1331       /usr/lib/libjson.so.0.1.0
7785a000-77869000 ---p 00000000 00:00 0
77869000-7786a000 rw-p 00000000 1f:00 1331       /usr/lib/libjson.so.0.1.0
7786a000-7787d000 r-xp 00000000 1f:00 804        /lib/libpthread-0.9.33.2.so
7787d000-7788c000 ---p 00000000 00:00 0
7788c000-7788d000 r--p 00012000 1f:00 804        /lib/libpthread-0.9.33.2.so
7788d000-7788e000 rw-p 00013000 1f:00 804        /lib/libpthread-0.9.33.2.so
7788e000-77890000 rw-p 00000000 00:00 0
77890000-778d5000 r-xp 00000000 1f:00 1255       /usr/lib/libcurl.so.4.3.0
778d5000-778e4000 ---p 00000000 00:00 0
778e4000-778e6000 rw-p 00044000 1f:00 1255       /usr/lib/libcurl.so.4.3.0
778e6000-778f0000 r-xp 00000000 1f:00 1346       /usr/lib/libmicroxml.so.1.0
778f0000-778ff000 ---p 00000000 00:00 0
778ff000-77900000 rw-p 00009000 1f:00 1346       /usr/lib/libmicroxml.so.1.0
77900000-77904000 r-xp 00000000 1f:00 810        /lib/libubus.so
77904000-77913000 ---p 00000000 00:00 0
77913000-77914000 rw-p 00003000 1f:00 810        /lib/libubus.so
77914000-7791b000 r-xp 00000000 1f:00 809        /lib/libubox.so
7791b000-7792a000 ---p 00000000 00:00 0
7792a000-7792b000 rw-p 00006000 1f:00 809        /lib/libubox.so
7792b000-77934000 r-xp 00000000 1f:00 811        /lib/libuci.so
77934000-77943000 ---p 00000000 00:00 0
77943000-77944000 rw-p 00008000 1f:00 811        /lib/libuci.so
77944000-7794b000 r-xp 00000000 1f:00 793        /lib/ld-uClibc-0.9.33.2.so
77957000-7795a000 rw-p 00000000 00:00 0
7795a000-7795b000 r--p 00006000 1f:00 793        /lib/ld-uClibc-0.9.33.2.so
7795b000-7795c000 rw-p 00007000 1f:00 793        /lib/ld-uClibc-0.9.33.2.so
7fb30000-7fb51000 rwxp 00000000 00:00 0          [stack]
7fff7000-7fff8000 r-xp 00000000 00:00 0          [vdso]
MOHAMED
  • 41,599
  • 58
  • 163
  • 268
  • Maybe this can be useful: http://stackoverflow.com/questions/1401359/understanding-linux-proc-id-maps – dragosht Feb 11 '15 at 09:34

2 Answers2

1

For the binaries valgrind's massif tool is very useful. To help with processing the data I would also recommend massif-visualizer. Using these tools you can find which functions that are allocating memory and how much memory they hold at any specific time.

Given that your application is intended to run as a daemon, the most important consideration is that the memory usage remains constant throughout its lifetime.

Richard Corden
  • 21,389
  • 8
  • 58
  • 85
-1

You should take the shared libraries into account: https://en.wikipedia.org/wiki/Memory_footprint

fcr
  • 14
  • 2