---
name: "dtrace_dtmalloc"
section: "4"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/dtrace_dtmalloc"
---

# dtrace\_dtmalloc(4)

a DTrace provider for tracing kernel memory allocations by type

## 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)](/malloc/9.md) and [free(9)](/free/9.md) kernel functions to trace memory allocations by type. Refer to [malloc(9)](/malloc/9.md) 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)](/malloc/9.md) 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)](/malloc/9.md) 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

- In 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)](/dtrace/1.md), [tracing(7)](/tracing/7.md), [malloc(9)](/malloc/9.md)

## 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)](/uma/9.md) allocations.
