I wonder if there is a way to know the memory footprint of my binary executable coded in C language.
informations about binary executable : compiled with toolchain of OpenWrt branch (Attitude Adjustment) and its architecture is x86
I wonder if there is a way to know the memory footprint of my binary executable coded in C language.
informations about binary executable : compiled with toolchain of OpenWrt branch (Attitude Adjustment) and its architecture is x86
On a Linux/Unix system, you can use the
size
command for this, e.g. on my Ubuntu systemSince this is OpenWrt, if you have a different architecture, e.g. MIPS or ARM or something else, you must pick the
size
command of the appropriate toolchain, of course.The sections have the following meaning
text
denotes the code size of the executabledata
is initialized data section, e.g. variables, likeint v = 17;
orchar name[] = "Tom";
bss
is the uninitialized or simply0
initiailized section,int a;
ordouble amount;
dec
is the overall size, in this case102134 + 1776 + 11272 = 115182
hex
finally is also the overall size, as a hex value1c1ee = 115182
But this does not include the stack or any dynamic heap memory. To see the overall memory usage at runtime, you must look at
ps
ortop
output.To understand your memory usage during runtime, on a Linux system you can use
valgrind
'smemcheck
tool.and advanced one called
are the tools to monitor any executable runing in linux system
Use the Command
size <binary>
to get the memory footprint of your binary executable. Check the size manual (man size
) for more information.