DTRACE_DTMALLOC(4) FreeBSD Kernel Interfaces Manual DTRACE_DTMALLOC(4)
NAME
dtrace_dtmalloc - a DTrace provider for tracing kernel memory allocations
by type
SYNOPSIS
dtmalloc::function:malloc
dtmalloc::function:free
DESCRIPTION
The dtmalloc provider instruments malloc(9) and free(9) kernel functions
to trace memory allocations by type. Refer to malloc(9) for more details
about malloc types.
The dtmalloc::function:malloc probe fires upon a successful allocation.
Its probe arguments are:
Probe Argument Definition
args[0] struct malloc_type *mtp
args[1] struct malloc_type_internal *mtip
args[2] struct malloc_type_stats *mtsp
args[3] unsigned long size
args[4] int zindx
The dtmalloc::function:free probe fires upon a free operation. Its probe
arguments are:
free Probe Argument Definition
args[0] struct malloc_type *mtp
args[1] struct malloc_type_internal *mtip
args[2] struct malloc_type_stats *mtsp
args[3] unsigned long size
args[4] Always 0
The first three arguments for each probe (i.e., mtp, mtip, and mtsp)
provide references to the malloc(9) type internals; size is the size of
the allocation; zindx is the index into the kmemzones[] array used for
the allocation. In practice, size is the most useful parameter to trace.
IMPLEMENTATION NOTES
The function part of the probe description in the dtmalloc provider is
the malloc(9) type short description with all whitespace characters
replaced with underscores. For example, a malloc type defined by
MALLOC_DEFINE(M_FOO_BAR, "foo bar", "FooBar subsystem");
will have probes called
dtmalloc::foo_bar:
FILES
<sys/malloc.h> The header where struct malloc_type is defined.
EXAMPLES
Example 1: Counting Successful Memory Allocations by Type
# dtrace -n 'dtmalloc:::malloc {@[stringof args[0]->ks_shortdesc] = count()}'
dtrace: description 'dtmalloc:::malloc ' matched 480 probes
^C
80211node 1
CAM CCB 1
CAM periph 1
ioctlops 1
netlink 1
soname 4
sysctltmp 4
solaris 5
acpica 16
temp 36
lkpikmalloc 44
iov 100
selfd 648
SEE ALSO
dtrace(1), tracing(7), malloc(9)
AUTHORS
dtrace_dtmalloc was written by John Birrell <jb@FreeBSD.org>.
This manual page was written by Mateusz Piotrowski <0mp@FreeBSD.org>.
CAVEATS
The dtmalloc provider does not trace uma(9) allocations.
FreeBSD 15.1-STABLE-HBSD May 12, 2026 DTRACE_DTMALLOC(4)