UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2012-02-25 07:44 PM

useless79
Member
Registered: 2011-10-10
Posts: 30

size command in linux

hi,

why size command does not show size of heap and stack segments ?

#size a.out
   text       data        bss        dec               hex            filename
   1663        376          8               2047                7ff     a.out

is there any command to show these values ?

what is hex and dec columns in the command output ?

thanks...........

Offline

#2 2012-02-26 04:14 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,826
Website

Re: size command in linux

The dynamic heap and the stack are both run-time things, not actually stored in the binary file...  Both of those grow on demand as needed...  "size" is just showing you sections stored in the actual binary: "text" is the code (and maybe any read-only data), "data" is initialized global/static variables and maybe some other stuff, and "bss" is uninitialized globals/statics (which will automatically get set to 0/NULL)...  The "dec" and "hex" columns are just showing you the grand total section size in decimal and hexidecimal respectively...  Try "size -A" for an alternate output format, which will likely break it down into more separate sections than just those 3...  You can also get at the sections with "objdump" and "readelf"...

Offline

#3 2012-02-27 08:35 AM

useless79
Member
Registered: 2011-10-10
Posts: 30

Re: size command in linux

is there any way to get stack and heap on fly ?
i mean any /proc file or any other mean which can show these values on run time ?
want to look virtual address space/memory consumption



thanks....

Offline

#4 2012-02-27 11:53 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: size command in linux

Look at /proc/$PID/maps and smaps.

Offline

Board footer

Powered by FluxBB