#include <kern/task_ref.h>
kern/task_ref.h
functiontask_reference
extern void task_reference(task_t)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/task_ref.c, osfmk/kern/task_ref.h
Takes a reference on the task, preventing it from being freed (though not from terminating). A TASK_NULL argument is ignored. References are tracked by reference group (kernel, external/kext, MIG) for leak triage; the kernel-internal form maps to the kernel group, and kext references get per-kext groups. Release with task_deallocate.
functiontask_deallocate
extern void task_deallocate(task_t)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/task_ref.c, osfmk/kern/task_ref.h
Releases a reference on the task obtained with task_reference or from the MIG conversion layer; when the last reference is dropped the task structure is torn down and freed. A TASK_NULL argument is ignored.