Repository navigation
Correct IMemoryPoolFactory documentation: custom factories don't inherit auto-eviction - #36716
Conversation
…vict Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
…sys docs Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
|
Looking over the original feature PR in the ASP.NET Core runtime repository: dotnet/aspnetcore#61554 - "Add IMemoryPoolFactory and cleanup memory pool while idle" Merged: June 9, 2025 Looking at the code: dotnet / aspnetcore / src / Shared / Buffers.MemoryPool / DefaultMemoryPoolFactory.cs dotnet / aspnetcore / src / Servers / Kestrel / Core / src / Internal / PinnedBlockMemoryPoolFactory.cs Why Custom Factories Don't Get Automatic Eviction: The automatic eviction logic is implemented in the factory classes themselves (DefaultMemoryPoolFactory and PinnedBlockMemoryPoolFactory), not in the IMemoryPoolFactory interface or the memory pool instances. When you register a custom IMemoryPoolFactory: The custom factory replaces the default factory |
|
Thanks @BrennanConroy! |
Documentation incorrectly stated that custom
IMemoryPoolFactoryimplementations benefit from automatic memory eviction. The eviction logic is implemented withinDefaultMemoryPoolFactoryandPinnedBlockMemoryPoolFactory, not inherited by custom implementations.Changes
Technical Detail
Changed from:
To:
Custom factories replace the default implementation entirely, so eviction must be explicitly implemented if desired.
Original prompt
This section details on the original issue you should resolve
<issue_title>Custom IMemoryPoolFactory does NOT benefit from the automatic eviction feature:</issue_title>
<issue_description>### Description
The documentation on this page states:
To use your own memory pool factory, make a class that implements IMemoryPoolFactory and register it with dependency injection, as the following example does. Memory pools created this way also benefit from the automatic eviction feature:When i look at the code:
https://github.com/dotnet/aspnetcore/blob/main/src/Shared/Buffers.MemoryPool/DefaultMemoryPoolFactory.csandhttps://github.com/dotnet/aspnetcore/blob/main/src/Servers/Kestrel/Core/src/Internal/PinnedBlockMemoryPoolFactory.csthis factory implements the automatic eviction feature. When we register a custom IMemoryPoolFactory this would replace the logic for automatic eviction feature. So the documentation on this should page state:To use your own memory pool factory, make a class that implements IMemoryPoolFactory and register it with dependency injection, as the following example does. Memory pools created this way do not benefit from the automatic eviction feature:Page URL
https://learn.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-10.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/release-notes/aspnetcore-10.0.md
Document ID
a7ad4b01-2333-32d8-b759-e044edfb9102
Platform Id
2f8fb8ab-5309-0a77-987a-c867c6517d2b
Article author
@wadepickett
Metadata
Related Issues
Associated WorkItem - 548836</issue_description>
Comments on the Issue (you are @copilot in this section)
@wadepickett Thank you @desdesdes for taking the time to bring this issue up. Greatly appreciated! @wadepickett ## 🤖 AI Triage SummaryThis preliminary assessment report was run by: @wadepickett
Date: 2026-01-29
Issue: 36700
Model: GitHub Copilot
Issue Analysis: Custom IMemoryPoolFactory does NOT benefit from the automatic eviction feature
✅ Issue Validation
Status: Valid and actionable
📋 Issue Summary
The issue highlights a technical inaccuracy in the ASP.NET Core 10.0 release notes. The documentation claims that custom
IMemoryPoolFactoryimplementations "also benefit from the automatic eviction feature." However, a review of the source code for both the built-in factories and custom registration patterns reveals this is not correct. If a customIMemoryPoolFactory<byte>is registered, it replaces the default logic — and thus, custom factories do not benefit from the automatic eviction feature unless they implement it themselves. The documentation should be updated for accuracy.📁 Potentially Affected Files
aspnetcore/release-notes/aspnetcore-10/includes/memory-eviction.mdSupporting product code:
DefaultMemoryPoolFactory.csPinnedBlockMemoryPoolFactory.cs📝 Preliminary Change Assessment
Potential Documentation Updates
File:
aspnetcore/release-notes/aspnetcore-10/includes/memory-eviction.mdLocation: Line 51
Type: Correction/clarification
Current content (line 51):
**Suggeste...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews