kinfo_getvmmap(3)

kinfo_getvmmap3

Function for getting per-process memory map information

Usage

#include <sys/types.h>

#include <sys/user.h>

#include <libutil.h>

struct kinfo_vmentry *

kinfo_getvmmap(pid_t pid, int *cntp);

Library

System Utilities Library (libutil, -lutil)

Overview

This function is used for obtaining virtual memory mapping information of a particular process.

The pid field contains the process identifier. This should be the a process that you have privilege to access. The cntp field is allows the caller to know how many records are returned.

This function is a wrapper around sysctl(3) with the KERN_PROC_VMMAP mib. While the kernel returns a packed structure, this function expands the data into a fixed record format.

Return values

On success the kinfo_getvmmap() function returns a pointer to an array of struct kinfo_vmentry structures as defined by ⟨sys/user.h⟩. The array was obtained by an internal call to malloc(3) and must be freed by the caller with a call to free(3). On failure the kinfo_getvmmap() function returns NULL.

Caveats

kinfo_getvmmap() calls can cause significant CPU consumption because calculating the residency counts requires iterating over all memory pages of the process. Setting the sysctl variable kern.proc_vmmap_skip_resident_count to 1 prevents this calculation.

Releases

41 releases since FreeBSD 7.3-RELEASE; the text changed 28 times.

  1. 7.3
  2. 7.4
  3. 8.0
  4. 8.1
  5. 8.2
  6. 8.3
  7. 8.4
  8. 9.0
  9. 9.1
  10. 9.2
  11. 9.3
  12. 10.0
  13. 10.1
  14. 10.2
  15. 10.3
  16. 10.4
  17. 11.0
  18. 11.1
  19. 11.2
  20. 11.3
  21. 11.4
  22. 12.0
  23. 12.1
  24. 12.2
  25. 12.3
  26. 12.4
  27. 13.0–13.1
  28. 13.2
  29. 13.3–16.0

History

The kinfo_getvmmap() function first appeared in FreeBSD 7.0.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.