Flyweight Pattern
Source:: Software Design Patterns - Best Practices for Software Developers
It aims to minimize the use of memory in an application by sharing as much data as possible with related objects (e.g. application configuration, state, and so on).
The pattern was first conceived by Paul Calder and Mark Linton in 1990 and was named after the boxing weight class.
The flyweight pattern is useful when you’re creating a huge number of objects, which could potentially drain all available RAM. It allows us to minimize the amount of consumed memory.
Usually, we don’t want the clients to create the flyweight objects directly. A flyweight factory is used to manage the flyweight objects.
# vs. Singletons
Flyweights are immutable whereas a singleton can undergo changes. Also, a singleton can only have a single copy whereas flyweights can have more than one object of their type.