How to find out the memory size of my binary executable

I wonder if there is a way to find out the amount of memory of my binary executable file encoded in C.

binary executable information : compiled using the OpenWrt tool chain (Attitude Adjustment), and its architecture is x86

+3
source share
3 answers

On a Linux / Unix system, you can use the size command for this, for example. on my ubuntu system

 size /bin/sh text data bss dec hex filename 102134 1776 11272 115182 1c1ee /bin/sh 

Since this is OpenWrt, if you have a different architecture, for example. MIPS or ARM or something else, you should choose the size command of the corresponding toolchain, of course.

Sections have the following meanings

  • text indicates the size of the executable file code
  • data is a section of initialized data, for example. variables such as int v = 17; or char name[] = "Tom";
  • bss is an uninitialized or simply 0 initiailized section, int a; or double amount;
  • dec is the total size, in this case 102134 + 1776 + 11272 = 115182
  • hex Finally, this is also the total size, as the hexadecimal value 1c1ee = 115182

But this does not include the stack or heap dynamic memory. To see the total memory usage at runtime, you should look at ps or top .

+9
source

To understand your memory usage at runtime, on a Linux system, you can use valgrind memcheck .

+2
source
 top 

and advanced called

 htop 

- tools for monitoring any executable run on linux system.

0
source

Source: https://habr.com/ru/post/1235542/


All Articles