IT lexicon › Programming › Dirty flag

Dirty flag

Programming På svenska → Updated: 2026-10-24

A boolean that marks data as changed, so expensive recomputation happens only when something actually moved — not every frame.

One of the oldest optimisation patterns in games, documented among others in Robert Nystrom's Game Programming Patterns. A node's world transform, a UI layout or a GPU buffer is recomputed only when the flag is set, and the flag is cleared afterwards. Set it on a parent and you spare yourself touching untouched children.

The price is a familiar class of bugs: forget to set the flag and stale data shows. It is fundamentally the same problem as cache invalidation — one of the two hard things in computer science. The pattern pays off the moment the recomputation costs more than a single boolean test.

← Back to the lexicon