COM+ Object Pooling

The ObjectPooling attribute is used to configure every aspect of your component’s object pooling. The ObjectPooling attribute enables or disables object pooling and sets the minimum or maximum pool size and object creation timeout. For example, to enable object pooling of your component’s objects with a minimum pool size of 3, a maximum pool size of 10, and a creation timeout of 20 milliseconds, you would write:

[ObjectPooling(MinPoolSize = 3,MaxPoolSize = 10,CreationTimeout = 20)]
public class MyComponent :ServicedComponent
{...}

The MinPoolSize , MaxPoolSize , and CreationTimeout properties are public properties of the ObjectPooling attribute class. If you do not specify values for these properties (all or just a subset) when your component is registered, the default COM+ values are used for these properties (a minimum pool size of 0, a maximum pool size of 1,048,576, and a creation timeout of 60 seconds).

The ObjectPooling attribute has a Boolean property called the Enabled property. If you do not specify a value for it (true or false), the attribute’s constructor sets it to true. In fact, the attribute’s constructor has a few overloaded versions—a default constructor that sets the Enabled property to true and a constructor that accepts a Boolean parameter. All constructors set the pool parameters to the default COM+ value. As a result, the following three statements are equivalent:

[ObjectPooling] [ObjectPooling(true)] [ObjectPooling(Enabled = true)] ...

Get COM & .NET Component Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.