Jump to content

Object pool pattern

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Christoofar (talk | contribs) at 18:19, 5 October 2005 (created the term object pool). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In computer programming, an object pool is a construct of objects which can be used concurrently. In a typical situation, an object which requires resources which are managed by the object pool will request an object and perform operations on that object. Object pooling offers a significant performance boost and is most efficient in situations where the cost of initializing a class instance is high and the amount of instantiations of a particular class is also frequent.

If no objects are available in the pool, a new object is created and returned to the pool when it has been dereferenced (it's no longer being used). This allows for control of resources and limits the amount of work necessary to instantiate and initialize new objects. The object pool will release objects within the pool when requests for objects diminishes.

This contruct is typically employed in software in situations where instantiating an object is prohibitively expensive, or the object itself uses a significant amount of resources and must be controlled in a fixed pool size.