Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: What is the best way to estimate the code & static data size of program?

Tags:

c++

linux

unix

I want to be able to get an estimate of how much code & static data is used by my C++ program?

Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime?

Will objdump & readelf help?

like image 706
hyperlogic Avatar asked Feb 03 '26 22:02

hyperlogic


1 Answers

"size" is the traditional tool. "readelf" has a lot of options.

$ size /bin/sh
   text    data     bss     dec     hex filename
 712739   37524   21832  772095   bc7ff /bin/sh
like image 125
Mark Harrison Avatar answered Feb 06 '26 12:02

Mark Harrison



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!