Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The pool manager internally uses a stack to manage the available objects in the pool. It's important to understand how a pool works. The flow diagram below shows how the pool manager deals with objects:

Gliffy
namePool Manager

It is recommended that a pool manager gets registered in the ServiceLocator so it can be re-used by multiple components.

Note

Note that the pool manager does not limit the number of objects in memory. It has a MaxSize property so it will store only a maximum amount of objects inside the internal pool, but if the pool is running out of instances and a new object is requested, it will return a new instance (and thus creating a new object which could be garbage collected).

...

Code Block
var poolManager = new PoolManager<Buffer4096Poolable>();
poolManager.MaxSize = 1024 * 1024 * 1;

If the MaxSize is reached, objects will not be added back to the internal pool but be left out and, if no other references exist to this object, be ready for garbage collection.

Creating a poolable object

...