What is the Flyweight Pattern?

Updated Apr 28, 2026

Short answer

A structural pattern that lets you fit more objects into the available amount of RAM by sharing common parts of state between multiple objects.

Deep explanation

It separates intrinsic state (shared, immutable) from extrinsic state (unique, context-specific). Intrinsic states are stored in flyweight objects, heavily reducing memory usage when dealing with millions of objects.

Real-world example

Rendering a massive forest in a video game. Instead of millions of trees having their own texture data, they share a few TreeType flyweights.

Common mistakes

  • Applying Flyweight when memory is not a bottleneck, needlessly complicating the codebase.

Follow-up questions

  • What is Intrinsic vs Extrinsic state?

More Design Patterns interview questions

View all →