IT lexicon › Programming › Capture tracking

Capture tracking

Programming På svenska → Updated: 2026-11-07

The analysis that decides whether a copy of a pointer can outlive the code that received it — a low-level cousin of escape analysis.

A pointer is captured if something squirrels it away: in global memory, in a struct that lives on, or as a return value. If a local variable's address is never captured, the compiler knows no other code can reach it, so not even a call to an unknown function can change it. That is often the difference between a value staying in a register and being reloaded after every call.

LLVM keeps the analysis in a file of its own, CaptureTracking.cpp, and records the result as parameter attributes: for years nocapture, now a finer-grained captures(...) that distinguishes leaking just the address from leaking what it points to. Unlike escape analysis in Java and Go compilers, the point isn't moving objects onto the stack but giving alias analysis more to work with.

← Back to the lexicon