A thought on Object Pool design pattern


Object pool is not an original design pattern from Design Patterns book. Nevertheless, it is a design pattern. 

Here is definition from wikipedia:

 

In computer programming, an object pool is a software design pattern. An object pool is a set of initialised objects that are kept ready to use, rather than allocated and destroyed on demand. A client of the pool will request an object from the pool and perform operations on the returned object. When the client has finished with an object, it returns it to the pool, rather than destroying it. It is a specific type of factory object.

Object pooling can offer a significant performance boost in situations where the cost of initializing a class instance is high, the rate of instantiation of a class is high, and the number of instances in use at any one time is low. The pooled object is obtained in predictable time when creation of the new objects (especially over network) may take variable time.

 

At my old work, we ran into expensive  memory allocation/destroy problem and came up with the same thing.

I wonder how many people went thru the same problem and came up the same solution and later found out that it had already been solved.

Learning is important to shorten the development time.

Advertisements
A thought on Object Pool design pattern

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s