-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add IMemoryPoolFactory and cleanup memory pool while idle #61554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
hostBuilder.ConfigureServices(services => | ||
{ | ||
// Don't override an already-configured transport | ||
services.TryAddSingleton<IConnectionListenerFactory, SocketTransportFactory>(); | ||
//services.TryAddSingleton<IConnectionListenerFactory, SocketTransportFactory>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//services.TryAddSingleton<IConnectionListenerFactory, SocketTransportFactory>(); |
/// <summary> | ||
/// Optional callback to call when pool is being disposed. | ||
/// </summary> | ||
public Action<PinnedBlockMemoryPool>? DisposeCallback { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OnBlockDisposed?
} | ||
|
||
// https://github.com/dotnet/runtime/blob/db681fb307d754c3746ffb40e0634e4c4e0caa9e/docs/design/features/ScalableApproximateCounting.md | ||
static void ScalableCount(ref uint counter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's #if
'd out.... is this here just in case you find you have false sharing?
|
||
#nullable enable | ||
|
||
internal sealed class DefaultMemoryPoolFactory : IMemoryPoolFactory<byte>, IDisposable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IAsyncDisposable and capture the task and wait for it to end?
|
||
_pools.TryAdd(pool, pool); | ||
|
||
pool.DisposeCallback = (self) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not a big deal, but we can avoid the closure if you passed in state to the registration 😄
Closes #61003