What is object  pooling ?

Object pooling is a design pattern where an array of ready-to-use objects is stored. Every time a request is made for a new object, the pool manager will accept it and fulfill it by allocating an object from the pool.

Why is it needed ?

It’s useful when the objects that are being managed are subjected to the following: • Whenever the same classes are instantiated repeatedly. • When allocation or initialization of an object is expensive. • When objects are used regularly and consistently.

Pooling strategies

Consider the following approaches when implementing your object pool: • If the application needs an object but the maximum number of objects is already allocated in the pool, an exception should be thrown or the app should return null. • Calls will be blocked until the object is available. • To store more objects, the pool can increase its size.

Pool forms

Object pooling has two forms: • An object is pulled from the pool on activation of the object. • An object is added to the pool on deactivation.

Pros of object pooling

• It is similar to database connection pooling. • With the help of object pooling, objects in .NET can be reused   repeatedly without having to be created from scratch. • Improves performance when the initialization of an object is   expensive.

Cons of object pooling

• There is a restriction on the number of objects that the object pool will keep, not the number of objects it will allocate. • The pool is not de-allocated until all the objects managed by the pool are de-allocated.

2X faster app development !

Syncfusion offers over 1,800 components and frameworks for WinForms, WPF, ASP.NET (MVC, Core), UWP, WinUI, .NET MAUI, Xamarin, Flutter, Blazor, JavaScript, Angular, Vue, and React that make developers’ work easier.