Re: Producing memory traces of C storage allocation?

Graeme Roy <graeme@epc.co.uk>
2 Jul 2001 00:30:54 -0400

          From comp.compilers

Related articles
Producing memory traces of C storage allocation? ratatat@army.net (2001-06-28)
Re: Producing memory traces of C storage allocation? joachim_d@gmx.de (Joachim Durchholz) (2001-07-02)
Re: Producing memory traces of C storage allocation? graeme@epc.co.uk (Graeme Roy) (2001-07-02)
Re: Producing memory traces of C storage allocation? gneuner@dyn.com (2001-07-02)
Re: Producing memory traces of C storage allocation? frido@q-software-solutions.com (Friedrich Dominicus) (2001-07-17)
| List of all articles for this month |

From: Graeme Roy <graeme@epc.co.uk>
Newsgroups: comp.compilers
Date: 2 Jul 2001 00:30:54 -0400
Organization: Analog Devices, Inc.
References: 01-06-065
Keywords: storage, C
Posted-Date: 02 Jul 2001 00:30:54 EDT

Hi,


The mpatrol toolkit is capable of logging, profiling and tracing all calls
to C/C++ memory allocation routines for a given program, and can produce
statistics about the overall allocation behaviour for specific runs.


On UNIX and Windows it can trap all calls to malloc(), free(), etc, even
ones originating from library routines (although Windows DLLs will need
to be recompiled with support for mpatrol). Unfortunately, it does not
catch calls to sbrk(), mmap() or VirtualAlloc() so if your application
uses these directly then you may need to resort to commercial heap
profilers.


Changing a compiler to log calls to malloc() and free() would have exactly
the same effect as wrapping such calls using the preprocessor and a
special header file. However, performing the wrapping at link time
allows you to catch calls from third party libraries rather than calls
from just the object files that were recompiled with tracing enabled.


The mpatrol toolkit is located at:


http://www.cbmamiga.demon.co.uk/mpatrol/


A list of over 80 items of related software (for detecting memory leaks,
heap corruption, memory usage profiling) can be found at:


http://www.cbmamiga.demon.co.uk/mpatrol/mpatrol_83.html


If you find that mpatrol does not meet your requirements, you're bound to
find something in the above list that will be suitable.


Graeme.




On 28 Jun 2001, Corndog wrote:


> Hmm..this is quite the question Im sure, but does anyone know of a C
> compiler or is anyone able to tell me how to create one (roars of
> laughter) that is able to force the program being generated to log all
> calls to memory allocation routines like malloc and free in order for
> me to be able to determine the size of the heap at any point during
> the program execution?


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.