Object pool
From CSSEMediaWiki
Revision as of 12:11, 14 September 2009 by Stephen Fitchett (Talk | contribs)
The object pool design pattern can be used to aid performance when objects are expensive to create, by using caching. An object pool, usually implemented as a Singleton class, manages a pool of objects that have already been instantiated. Clients can request objects from the pool instead of creating them and return them once they are done with them.
An object pool should be considered when:
- There is a high cost of creating new objects of a particular type
- The rate of instantiation is high
- The number of instantiations in use at a particular time is low
Care should be taking not to use Premature optimization when considering this pattern, and also to avoid creating an Object cesspool.