This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Static And Dynamic Memory Usage Of An Executable
- From: Sandeep Kumar <sandeepksinha at gmail dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: Steven Woody <narkewoody at gmail dot com>, binutils <binutils at sources dot redhat dot com>
- Date: Sun, 20 Nov 2005 22:47:14 -0800
- Subject: Re: Static And Dynamic Memory Usage Of An Executable
- References: <87hdae3v8t.fsf@narke.yellow.line> <437BD719.50908@redhat.com>
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