Static And Dynamic Memory Usage Of An Executable
Sandeep Kumar
sandeepksinha@gmail.com
Mon Nov 21 06:47:00 GMT 2005
On 11/16/05, Nick Clifton <nickc@redhat.com> wrote:
> Hi Steven,
>
> > in static, i want to know what is the size of each segment, i.e. heap, data,
> > text,
>
> The "size" program can give you the information about the data and text
> segments. Alternatively you might prefer to use the "objdump" program.
> If the heap is actually a segment, then it should show up in the listing
> provided by objdump, but for a lot of systems the heap is not actually a
> segment, but rather the memory space between two symbols. In this case
> you will need to use the "objdump" or "nm" programs to obtain the values
> of these symbols and then perform the necessary arithmetic to compute
> the heap size.
> > in dynamic, i want to know, what size of heap and stack is enough to run
> > the program ( a runtime memory usage graph ).
>
> There is no GNU utility to collect this information for you. You will
> have to write your own.
We do have valgrind under the GNU utilities. It is a runtime memory
profiler which can give us asll the information about the runtime
allocation of memory.
>You can take advantage of the hook inserted by
> gcc when it is compiling code for profiling. This hook is a call to a
> special external function which is made at the start of every function
> compiled by gcc. Usually this function would record the address of the
> function and maybe the time as well, but you could have it record the
> current stack and heap pointers. See the gcc documentation for more
> information.
Try valgrinf , it has a tool memprof. It will give you all the details
about runtime allocation of memory tht u reuqire.
--
Regards,
Sandeep
More information about the Binutils
mailing list