What is an object pool in C#?


Object pool is a software construct designed to optimize the usage of limited resources. It has objects that are ready to be used.

The pooled objects can be reused. The object pooling has two forms −

  • On activation of the object, it is pulled from pool.
  • On deactivation, the object is added to the pool.

Configure object pooling by applying the ObjectPoolingAttribute attribute.

This is applied to a class deriving from the System.EnterpriseServices.ServicedComponent class.

To understand how a pool behaves, the Diagnostics class has informational properties. Through this, you can check the behavior under dissimilar scenarios.

The usage of Object pool can be understood when a part of an application performance is bound to its resources. At that time, the resources are formed and aborted, the object pool enhances performance.

Updated on: 22-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements