IT lexicon › Programming › Flyweight pattern

Flyweight pattern

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

Letting thousands of objects share whatever they have in common, so each carries only what makes it different.

The pattern splits an object's state in two: intrinsic state (the mesh, texture and stats for a kind of tree) that is shared and stored once, and extrinsic state (position, scale, health) that belongs to each instance. A forest of ten thousand trees becomes ten thousand small records pointing at the same heavy data. Paul Calder and Mark Linton described the idea in 1990 for text rendering in InterViews, where every glyph was an object, and the Gang of Four named it in 1994.

In games the pattern is so fundamental that hardware absorbed it: GPU instancing is a flyweight with a buffer of extrinsic state and a single draw call.

← Back to the lexicon