Malloc trace

Malloc Trace provides an optional extension to the malloc subsystem for use with the trace facility.

Traces of the malloc, realloc, and free subroutines are recorded for use in problem determination and performance analysis.

Malloc Trace is not enabled by default, but can be enabled and configured prior to process startup through the MALLOCDEBUG environment variable.

Events recorded by malloc trace

The tracehook IDs used for Malloc Trace are as follows:
  • HKWD_LIBC_MALL_SUBSYSTEM
  • HKWD_LIBC_MALL_INTERNAL

When tracing is enabled for HKWD_LIBC_MALL_SUBSYSTEM, the input parameters, as well as return values for each call to malloc, realloc, and free subroutines are recorded in the trace subsystem.

When tracing is enabled for HKWD_LIBC_MALL_INTERNAL and the Malloc Detect debugging tools are enabled, Malloc Trace will log a trace event whenever Malloc Detect detects an error in the internal data structures of the malloc subsystem.

Enabling malloc trace

Malloc Trace is not enabled by default. It is enabled and configured by setting the MALLOCDEBUG environment variable. To enable Malloc Trace, set the MALLOCDEBUG environment variable by typing the following on the command line:
MALLOCDEBUG=trace
To enable other Malloc Debug features, set the MALLOCDEBUG environment variable as follows:
MALLOCDEBUG=[trace, other_option]

Limitations