vfree(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… vfree(9) β€” the Kernel API Manual glow-up

okay so welcome to the Kernel API Manual bestie, today we're doing vfree(9) and honestly? she's the cleanup queen. every icon needs a friend who handles the goodbye, and this is hers 🫢


✨ NAME ✨

vfree β€” release memory allocated by vmalloc()

like, the memory's done, she's served her purpose, time to let her go 🌸


✨ SYNOPSIS ✨

void vfree (const void *addr );

✨ ARGUMENTS ✨

  • addr β€” memory base address. the starting point, the root of the situation, the address of the memory you want freed πŸ’–

✨ DESCRIPTION ✨

okay so here's the vibe: vfree frees the virtually continuous memory area starting at addr, as obtained from one of the vmalloc family of APIs. so if vmalloc handed it to you, vfree is the one who takes it back. no cap.

this will usually also free the physical memory underlying the virtual allocation β€” BUT πŸ‘€ that memory is reference counted, so it will not be freed until the last user goes away. it's giving "she's not leaving until the whole group chat is done with her" energy. literally the last one out turns off the lights 😭

and if addr is NULL? no operation is performed. nothing happens. she looks at it, says "not my problem", and moves on πŸ’…


✨ CONTEXT ✨

may sleep if called not from interrupt context. so like, she's allowed a lil nap in normal vibes πŸ’€

must not be called in NMI context. strictly speaking, it could be if we have CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG β€” but making the calling conventions for vfree arch-dependent would be a really bad idea, and we don't do bad ideas here πŸ™ˆ

fr fr do not call this in NMI context. the code might technically go through in that one config, but the design would be cursed and nobody wants that.

✨ SEE ALSO ✨

kernel file ./mm/vmalloc.c

the whole friend group πŸ‘‘ β€” go say hi:


okay that's the whole page bestie, you ate that πŸ“

source: ./mm Β· version: Kernel API Manual Β· date: October 2026 Β· page: vfree(9) β€” mwah, go free some memory responsibly πŸ’œβœ¨

πŸ“¦ where this page comes from