PRLEAK(8)

NAME
prleak - aid for debugging programs using malloc/free

SYNOPSIS
prleak [ -a ] [ -d ] [ -l ] [ objfile [ tracefile ] ]

DESCRIPTION
Prleak is a tool for use in debugging programs that make use of Magic's versions of malloc and free. It examines the trace file produced by special versions of malloc and free produced when they are compiled with the -DMALLOCTRACE flag. The output of prleak is the average allocation size, a list of `leaky' allocations (blocks still allocated at program exit) if -l is specified, a list of duplicate frees (blocks that the program attempted to free after they had already been deallocated) if -d is specified, and a list of all calls to malloc and free if -a is specified. If no switches are given, the default action is as though -l and -d were in effect.

For each entry output, both the address of the allocated block and a stack backtrace at the time of the call to malloc or free are printed. Prleak attempts to use the namelist from objfile (a.out if no file is given) to produce a symbolic backtrace. If no namelist can be found, the backtrace is printed in hex. If tracefile is specified, the malloc trace is read from it; otherwise, it is read from the file malloc.out in the current directory.

An example output might be as follows:

    Average allocation size = 12 bytes
    ------
    Leaks:
    ------
    0x11540      [11 bytes]
            at _foo+0x14
            called from ~main+026
    0x11556      [14 bytes]
            at _bar+0x50
            called from _foo+0x36
            called from ~main+0x26
    --------- ------
    Duplicate frees:
    --------- ------
    0x11556
            at _bar+0x40
            called from _foo+0x36
            called from ~main+0x26

FILES
malloc.out

SEE ALSO
ACM SIGPLAN Notices, Vol 17, No 5 (May 1982), the article by Barach and Taenzer.

AUTHOR
Walter Scott

BUGS
Local symbols (beginning with ``~'') in the backtrace output should be tagged with the source file to which they refer.