CS FundamentalsVery hardGATE CS · TCS NQT Prime · Product Company SDE

A text editor needs to render a document containing a million characters without creating a million separate heavyweight glyph objects, by sharing the common, immutable parts of similar objects. Which pattern addresses this memory concern specifically?

  1. A. Flyweight pattern
  2. B. Observer pattern
  3. C. Prototype pattern
  4. D. Singleton pattern

Correct answer: A. Flyweight pattern

Flyweight shares as much intrinsic (context-independent) state as possible between many fine-grained objects, drastically cutting memory use when a huge number of similar objects would otherwise be needed.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic