Browse Java Design Patterns & Enterprise Application Architecture

Flyweight Pattern

Use the Flyweight pattern in Java when large numbers of similar objects make shared immutable state worth the extra discipline.

Flyweight is the structural pattern for trading object duplication for shared state plus context supplied from outside.

It is narrower than many pattern catalogs make it sound. In Java, Flyweight is useful only when all of these are true:

  • the system creates many logically similar objects
  • a significant portion of their state can be shared safely
  • the cost of many separate objects is actually measurable

Without those conditions, Flyweight usually adds complexity faster than it saves memory.

In this section

Revised on Thursday, April 23, 2026