Skip to content

Correct IMemoryPoolFactory documentation: custom factories don't inherit auto-eviction - #36716

Merged
wadepickett merged 3 commits into
mainfrom
copilot/update-imemorypoolfactory-docs
Jan 29, 2026
Merged

wadepickett merged 3 commits into
mainfrom
copilot/update-imemorypoolfactory-docs

Conversation

Copilot AI commented Jan 29, 2026 •

Copy link
Copy Markdown
Contributor

Documentation incorrectly stated that custom IMemoryPoolFactory implementations benefit from automatic memory eviction. The eviction logic is implemented within DefaultMemoryPoolFactory and PinnedBlockMemoryPoolFactory, not inherited by custom implementations.

Changes

  • aspnetcore/release-notes/aspnetcore-10/includes/memory-eviction.md - Corrected statement about custom factory behavior
  • aspnetcore/fundamentals/servers/kestrel/memory-management.md - Same correction
  • aspnetcore/fundamentals/servers/includes/memory-eviction2.md - Same correction
  • aspnetcore/release-notes/aspnetcore-10.0.md - Updated metadata (ms.date, ai-usage)
  • aspnetcore/fundamentals/servers/httpsys.md - Updated metadata (ms.date, ai-usage)

Technical Detail

Changed from:

Memory pools created this way also benefit from the automatic eviction feature

To:

Memory pools created this way do not benefit from the automatic eviction feature unless you implement similar eviction logic in your custom factory

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.cs and https://github.com/dotnet/aspnetcore/blob/main/src/Servers/Kestrel/Core/src/Internal/PinnedBlockMemoryPoolFactory.cs this 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

  • ID: a7ad4b01-2333-32d8-b759-e044edfb9102
  • PlatformId: 2f8fb8ab-5309-0a77-987a-c867c6517d2b
  • Service: aspnet-core
  • Sub-service: release-notes

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 Summary

📌 Note to community: This is an automated preliminary analysis to help our documentation team quickly review, determine scope and prioritize this issue. This report is not a resolution or final decision. Please review and supplement with your expertise as needed.


This 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 IMemoryPoolFactory implementations "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 custom IMemoryPoolFactory<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

These files have been identified as possibly related to this issue and may need review.

File Path Lines Section
Include file aspnetcore/release-notes/aspnetcore-10/includes/memory-eviction.md 51 "Manage memory pools"

Supporting product code:

📝 Preliminary Change Assessment

The following are initial observations for the documentation team to evaluate—not final decisions.

Potential Documentation Updates

File: aspnetcore/release-notes/aspnetcore-10/includes/memory-eviction.md
Location: Line 51
Type: Correction/clarification

Current content (line 51):

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:

**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

📄 File 🔗 Preview link
aspnetcore/fundamentals/servers/httpsys.md aspnetcore/fundamentals/servers/httpsys
aspnetcore/fundamentals/servers/kestrel/memory-management.md aspnetcore/fundamentals/servers/kestrel/memory-management
aspnetcore/release-notes/aspnetcore-10.0.md aspnetcore/release-notes/aspnetcore-10.0

Copilot AI and others added 2 commits January 29, 2026 22:51
…vict

Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
…sys docs

Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation for IMemoryPoolFactory automatic eviction Correct IMemoryPoolFactory documentation: custom factories don't inherit auto-eviction Jan 29, 2026
Copilot AI requested a review from wadepickett January 29, 2026 22:54
@wadepickett

wadepickett commented Jan 29, 2026 •

Copy link
Copy Markdown
Contributor

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
Milestone: 10.0-preview6
This PR introduced the IMemoryPoolFactory interface and the automatic memory eviction feature for Kestrel, IIS, and HTTP.sys.

Looking at the code:

dotnet / aspnetcore / src / Shared / Buffers.MemoryPool / DefaultMemoryPoolFactory.cs
internal sealed class DefaultMemoryPoolFactory : IMemoryPoolFactory, IAsyncDisposable
{
// The eviction logic is INSIDE this factory class
private readonly PeriodicTimer _timer;
private readonly Task _timerTask;

dotnet / aspnetcore / src / Servers / Kestrel / Core / src / Internal / PinnedBlockMemoryPoolFactory.cs
internal sealed class PinnedBlockMemoryPoolFactory : IMemoryPoolFactory, IHeartbeatHandler
{
// Kestrel's factory uses its heartbeat loop for eviction
public void OnHeartbeat()
{
foreach (var pool in _pools)

Why Custom Factories Don't Get Automatic Eviction:
"Kestrel makes use of its heartbeat loop to clean up the memory pools, whereas IIS and HttpSys don't have the equivalent so they use a PeriodicTimer approach."

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
The PeriodicTimer or heartbeat-based eviction code does not transfer to your implementation
You must implement your own eviction logic if you need it

@wadepickett
wadepickett marked this pull request as ready for review January 29, 2026 23:49
@wadepickett

Copy link
Copy Markdown
Contributor

Thanks @BrennanConroy!

@wadepickett
wadepickett merged commit c1f0d17 into main Jan 29, 2026
2 checks passed
@wadepickett
wadepickett deleted the copilot/update-imemorypoolfactory-docs branch January 29, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom IMemoryPoolFactory does NOT benefit from the automatic eviction feature:

3 participants