VOOZH about

URL: https://www.nuget.org/packages/Microsoft.Extensions.ObjectPool.DependencyInjection/

⇱ NuGet Gallery | Microsoft.Extensions.ObjectPool.DependencyInjection 10.7.0




👁 Image
Microsoft.Extensions.ObjectPool.DependencyInjection 10.7.0

Prefix Reserved
dotnet add package Microsoft.Extensions.ObjectPool.DependencyInjection --version 10.7.0
 
 
NuGet\Install-Package Microsoft.Extensions.ObjectPool.DependencyInjection -Version 10.7.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Extensions.ObjectPool.DependencyInjection" Version="10.7.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Extensions.ObjectPool.DependencyInjection" Version="10.7.0" />
 
Directory.Packages.props
<PackageReference Include="Microsoft.Extensions.ObjectPool.DependencyInjection" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Extensions.ObjectPool.DependencyInjection --version 10.7.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Microsoft.Extensions.ObjectPool.DependencyInjection, 10.7.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Microsoft.Extensions.ObjectPool.DependencyInjection@10.7.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Microsoft.Extensions.ObjectPool.DependencyInjection&version=10.7.0
 
Install as a Cake Addin
#tool nuget:?package=Microsoft.Extensions.ObjectPool.DependencyInjection&version=10.7.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Microsoft.Extensions.ObjectPool.DependencyInjection

This provides the ability to retrieve pooled instances that can be initialized using dependency injection.

Install the package

From the command-line:

dotnet add package Microsoft.Extensions.ObjectPool.DependencyInjection

Or directly in the C# project file:

<ItemGroup>
 <PackageReference Include="Microsoft.Extensions.ObjectPool.DependencyInjection" Version="[CURRENTVERSION]" />
</ItemGroup>

Usage Example

Registering Pools

The object pools can be registered using the following methods:

public static IServiceCollection AddPooled<TService>(this IServiceCollection services, Action<DependencyInjectionPoolOptions>? configure = null)
public static IServiceCollection AddPooled<TService, TImplementation>(this IServiceCollection services, Action<DependencyInjectionPoolOptions>? configure = null)

For example:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton<MyService>();
builder.Services.AddPooled<MyPooledClass>();

var app = builder.Build();

Consuming Pools

Once registered, pools can be resolved using dependency injection. For example:

var pool = context.RequestServices.GetRequiredService<ObjectPool<MyPooledClass>>();

var obj = pool.Get();

// Use the pooled object ...

pool.Return(obj);

Pooled instances will be resolved from the root dependency injection container and can only use singleton dependencies.

Pooled instances can implement Microsoft.Extensions.ObjectPool.IResettable in order to be initialized when they are returned to the pool.

public class MyPooledClass : IResettable
{
 private MyService _myService;

 public MyPooledClass(MyService myService)
 {
 _myService = myService;
 }

 public bool TryReset()
 {
 // Clean instance here
 return true;
 }
}

Options

The DependencyInjectionPoolOptions.Capacity property is used to configure the maximum capacity of each pool. The default value is 1024.

This value can also be set during the pool registration:

builder.Services.AddPooled<MyPooledClass>(options => options.Capacity = 64);

Feedback & Contributing

We welcome feedback and contributions in our GitHub repo.

Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Framework net462 net462 is compatible.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Microsoft.Extensions.ObjectPool.DependencyInjection:

Package Downloads
Shinya.Core

Shinya.Framework

Microsoft.AspNetCore.HeaderParsing

Strong type header parsing

xSdk.Data

xSdk.Data - Base data layer abstractions and common utilities for the xSdk project.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.7.0 379 6/9/2026
10.6.0 2,247 5/12/2026
10.5.0 3,086 4/15/2026
10.4.0 559 3/10/2026
10.3.0 719 2/10/2026
10.2.0 1,454 1/13/2026
10.1.0 1,516 12/9/2025
10.0.0 899 11/11/2025
9.10.0 1,113 10/14/2025
9.9.0 1,050 9/9/2025
9.8.0 463 8/12/2025
9.7.0 565 7/8/2025
9.6.0 686 6/10/2025
9.5.0 676 5/13/2025
9.4.0 2,043 4/8/2025
9.3.0 727 3/11/2025
9.2.0 9,330 2/11/2025
9.1.0 850 1/14/2025
9.0.0 2,047 11/12/2024
8.10.0 4,560 10/8/2024
Loading failed