Glossary
kalloc
XNU's general-purpose kernel heap. A facade over the zone allocator using power-of-two-sized buckets; what kernel code calls when it needs malloc-like variable-size allocation.
kalloc is XNU's general-purpose kernel allocator — the kernel-side equivalent of malloc. It exists for allocations that don't have a dedicated zone, like temporary buffers and one-off kernel strings.
kalloc(n) rounds n up to the next power-of-two bucket and allocates from the bucket's underlying zone (kalloc.16, kalloc.32, kalloc.64, ...). Beyond the largest bucket, kalloc_large allocates whole pages directly.
The kernel's kfree(ptr, size) requires the caller to pass the original size — this saves the per-allocation bookkeeping malloc/free would otherwise need. Common bug source: passing the wrong size to kfree.
IOKit drivers usually call IOMalloc(n) / IOFree(ptr, n), which are thin wrappers around kalloc with some additional bookkeeping for the IOKit object model.
See also: zone allocator, and the kernel allocators article.