![]() |
VOOZH | about |
dotnet add package Microsoft.Extensions.ObjectPool.DependencyInjection --version 10.7.0
NuGet\Install-Package Microsoft.Extensions.ObjectPool.DependencyInjection -Version 10.7.0
<PackageReference Include="Microsoft.Extensions.ObjectPool.DependencyInjection" Version="10.7.0" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool.DependencyInjection" Version="10.7.0" />Directory.Packages.props
<PackageReference Include="Microsoft.Extensions.ObjectPool.DependencyInjection" />Project file
paket add Microsoft.Extensions.ObjectPool.DependencyInjection --version 10.7.0
#r "nuget: Microsoft.Extensions.ObjectPool.DependencyInjection, 10.7.0"
#:package Microsoft.Extensions.ObjectPool.DependencyInjection@10.7.0
#addin nuget:?package=Microsoft.Extensions.ObjectPool.DependencyInjection&version=10.7.0Install as a Cake Addin
#tool nuget:?package=Microsoft.Extensions.ObjectPool.DependencyInjection&version=10.7.0Install as a Cake Tool
This provides the ability to retrieve pooled instances that can be initialized using dependency injection.
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>
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();
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;
}
}
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);
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. |
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. |
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 |