Causing a trace and giving results
A program can cause a trace to be performed and memory leaks to be reported by calling the malloc_dump_unreferenced() function provided by the library:
int malloc_dump_unreferenced ( int fd, int detail );
Suspend all threads, clear the mark information for all heap buffers, perform the trace operation, and print a report of all memory leaks detected. All items are reported in memory order.
- The file descriptor on which the report should be produced.
- How the trace operation should deal with any heap corruption problems
- Any problems encountered can be treated as fatal errors. After the error encountered is printed, abort the program. No report is produced.
- Print case errors, and a report based on whatever heap information is recoverable.