This documentation is archived and is not being maintained.

ObjectPoolingAttribute.MaxPoolSize Property

Gets or sets the value for the maximum size of the pool.

Namespace:  System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)

public int MaxPoolSize { get; set; }

Property Value

Type: System.Int32
The maximum number of objects in the pool.

MaxPoolSize represents the maximum number of pooled objects that the pooling manager will create, both actively used by clients and inactive in the pool. When creating objects, the pooling manager checks to verify that the maximum pool size has not been reached and, if it has not, the pooling manager creates a new object to dispense to the client. If the maximum pool size has been reached, client requests are queued and receive the first available object from the pool in the order in which they arrived. Object creation requests time-out after a specified period.

The following code example demonstrates the use of this property.

[ObjectPooling(MinPoolSize=2, MaxPoolSize=100, CreationTimeout=1000)]
public class ObjectInspector : ServicedComponent

    public string IdentifyObject (Object obj)
        // Return this object to the pool after use.
        ContextUtil.DeactivateOnReturn = true;

        // Get the supplied object's type.        
        Type objType = obj.GetType();

        // Return its name.


    protected override void Activate()
        MessageBox.Show( String.Format("Now entering...\nApplication: {0}\nInstance: {1}\nContext: {2}\n",
                                       ContextUtil.ApplicationId.ToString(), ContextUtil.ApplicationInstanceId.ToString(),
                                       ContextUtil.ContextId.ToString() ) );

    protected override void Deactivate()
        MessageBox.Show("Bye Bye!");

    // This object can be pooled.
    protected override bool CanBePooled()


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.