Closed as not planned
Description
Description
In an automatic reconnection use case, the following code is executed in a timer. If the connection fails, it may cause a memory leak, possibly due to underlying handles not being released.
try
{
var quicCon = await QuicConnection.ConnectAsync(QuicOptions, cancel.Token);
}
catch
{
//It will attempt to reconnect again.
}
Reproduction Steps
internal class Program
{
static async Task Main()
{
await Task.Run(async () =>
{
if (!QuicConnection.IsSupported)
{
throw new PlatformNotSupportedException("QUIC protocol is not supported on this platform.");
}
CancellationTokenSource cancel = new();
using var pingTimer = new PeriodicTimer(TimeSpan.FromSeconds(1));
while (await pingTimer.WaitForNextTickAsync(cancel.Token))
{
try
{
await using var quicCon = await QuicConnection.ConnectAsync(new()
{
RemoteEndPoint = new IPEndPoint(IPAddress.Loopback, 9999),
DefaultCloseErrorCode = 0x0A,
DefaultStreamErrorCode = 0x0B,
ClientAuthenticationOptions = new SslClientAuthenticationOptions
{
ApplicationProtocols = [SslApplicationProtocol.Http3],
RemoteCertificateValidationCallback = (sender, certificate, chain, errors) => true,
TargetHost = "localhost"
},
}, cancel.Token);
break;
}
catch
{
//It will attempt to reconnect again.
}
}
});
Console.WriteLine("exit;");
Console.ReadLine();
}
}
Expected behavior
Normal memory.
Actual behavior
The memory will continue to grow without any signs of being reclaimed.
Regression?
No response
Known Workarounds
No response
Configuration
dotnet 9.0 win-x64 AOT publish
Other information
No response