KINFO_GETVMMAP(3)
πΈ NAME πΈ
okay bestie, welcome to KINFO_GETVMMAP(3) from the Library Functions Manual β this is all about kinfo_getvmmap, the function for getting per-process memory map information. π
β¨
π«Ά LIBRARY π«Ά
System Utilities Library (libutil, -lutil) β thatβs the vibe. π
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <sys/user.h>
#include <libutil.h>
struct kinfo_vmentry *
kinfo_getvmmap(pid_t pid, int *cntp);
π DESCRIPTION π
So this function is your go-to for obtaining virtual memory mapping information of a particular process. π
The pid field contains the process identifier. It should be a process that you have privilege to access β no sneaky peeking at stuff youβre not allowed to see, bestie. π
The cntp field is how the caller gets to know how many records are returned. Very demure, very useful. π
This function is a wrapper around sysctl(3) with the KERN_PROC_VMMAP mib. The kernel returns a packed structure, but this function expands the data into a fixed record format. Slay. β¨
π¦ RETURN VALUES π¦
On success, kinfo_getvmmap() returns a pointer to an array of struct kinfo_vmentry structures as defined by <sys/user.h>. That array was obtained by an internal call to malloc(3) and must be freed by the caller with a call to free(3). Donβt leave it hanging, bestie. π
On failure, kinfo_getvmmap() returns NULL. π
π₯ SEE ALSO π₯
π HISTORY π
The kinfo_getvmmap() function first appeared in FreeBSD 7.0. iconic behavior. π
π CAVEATS π
ngl, this one matters: 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. Consider that your built-in low-power mode. πβ¨
mwah π β this page is from Debian, dated May 10, 2020. π«Άπ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2008 Peter Wemm
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms