|Producing memory traces of C storage allocation? firstname.lastname@example.org (2001-06-28)|
|Re: Producing memory traces of C storage allocation? email@example.com (Joachim Durchholz) (2001-07-02)|
|Re: Producing memory traces of C storage allocation? firstname.lastname@example.org (Graeme Roy) (2001-07-02)|
|Re: Producing memory traces of C storage allocation? email@example.com (2001-07-02)|
|Re: Producing memory traces of C storage allocation? firstname.lastname@example.org (Friedrich Dominicus) (2001-07-17)|
|From:||"Joachim Durchholz" <email@example.com>|
|Date:||2 Jul 2001 00:30:04 -0400|
|Posted-Date:||02 Jul 2001 00:30:03 EDT|
Corndog <firstname.lastname@example.org> 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? Or is there another simpler more intelligent
> way of doing it? Just writing wrappers for them doesnt work (I think)
> cos I wont intercept such calls by library routines.
This depends on the setup of the library routines and the linker.
I've worked with a compiler that has a debug version of malloc/free; all
inter-library calls to malloc/free will use these.
As for the intra-library calls: the debug library already uses the debug
versions of malloc/free, so no need to worry.
> I also know I can
> just write a separate program that will monitor the heap size of a
> target program, only doing it this way I cannot make any guarantees
> about the shape of the resulting graph cos I cant control the way the
> OS decides to interleave the execution of the two! Right?
You can give the monitoring thread a higher priority and let it sleep.
This is good for gathering general time-related memory statistics, but
it's difficult to relate that statistics to actions within the
You could also try a tool like BoundsChecker, which tries to trace
memory leaks. Checking tools like this can even work without explicit
debugging support compiled into the software, though I don't know how
they do this.
Return to the
Search the comp.compilers archives again.