$> git checkout flyweight
Intent
Use sharing to support large numbers of fine-grained objects efficiently.1
Applications
The flyweight pattern is used to reduce memory footprint. You will find this pattern helpful whenever you are dealing with a large number of objects that share the same properties or a few objects that share the same large-size data (e.g. images). To illustrate, say you have a Person object that has properties like name, gender, and phone number. Assume the average memory cost for each Person object is 1,000 bytes. When you allocate 100,000 Person objects , you end up with 100 million ...