On 25 Jul 2008 at 20:53, santosh wrote:
Quote:
mohi wrote:
Quote:
>is there any cmmnd in gdb or any other way to find out whats the
>total dynamically allocated memory a process holds at various
>instances of execution???
>
You must keep track of this yourself, which you can do by means of
wrapping over malloc/realloc/calloc and free.
Of course, it's quite likely that malloc will have some overhead, for
example by rounding up allocation requests to a size related to a power
of 2. So the process might "hold" more bytes than the total sum of the
sizes passed to successful malloc calls not yet freed.
As the OP seems to be using a GNU system, he could try #include
<malloc.hand then use mallinfo() to fill in a struct mallinfo with
various pieces of information about the memory allocated in his process,
including an arena fields which gives "the total size of memory
allocated with sbrk by malloc, in bytes."
Quote:
Quote:
>and what can be the possible reasons of an error like
>>
>glibc detected:malloc() memory corruption
As others have said, valgrind is just the thing for getting to the
bottom of problems like this.