Fix memory leak: dispose linked CancellationTokenSource in ChannelAsyncOperation.EndAsync#3812
Merged
Merged
Conversation
…tion.EndAsync (#3809) On pre-.NET 6 targets (.NET Framework 4.8), CreateLinkedTokenSource was used without disposal. Each service call with a CancellationToken leaked a linked CTS registration, causing gradual memory growth.
Copilot created this pull request from a session on behalf of
romanett
May 27, 2026 19:05
View session
romanett
approved these changes
May 27, 2026
romanett
marked this pull request as ready for review
May 27, 2026 19:05
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master378 #3812 +/- ##
=============================================
- Coverage 60.09% 60.08% -0.01%
=============================================
Files 378 378
Lines 79043 79043
Branches 13833 13833
=============================================
- Hits 47499 47496 -3
+ Misses 27126 27124 -2
- Partials 4418 4423 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
marcschier
approved these changes
May 27, 2026
This was referenced Jun 26, 2026
GoetzGoerisch
pushed a commit
to umati/connect
that referenced
this pull request
Jul 2, 2026
…5.378.152 (#21) This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [OPCFoundation.NetStandard.Opc.Ua](https://github.com/OPCFoundation/UA-.NETStandard) | `1.5.378.145` → `1.5.378.152` |  |  | --- ### Release Notes <details> <summary>OPCFoundation/UA-.NETStandard (OPCFoundation.NetStandard.Opc.Ua)</summary> ### [`v1.5.378.152`](https://github.com/OPCFoundation/UA-.NETStandard/releases/tag/1.5.378.152): OPC UA 1.05 Maintenance Update [Compare Source](OPCFoundation/UA-.NETStandard@1.5.378.145...1.5.378.152) Maintenance Release for fixing bugs found on the main378 development branch. #### Released packages [OPCFoundation.NetStandard.Opc.Ua](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Core](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Core/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Security.Certificates](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Security.Certificates/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Configuration](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Configuration/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Server](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Server/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Client](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Client/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Bindings.Https](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Bindings.Https/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.PubSub](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.PubSub/1.5.378.152) #### What's Changed - Fix memory leak: dispose linked CancellationTokenSource in ChannelAsyncOperation.EndAsync by [@​romanett](https://github.com/romanett) with [@​Copilot](https://github.com/Copilot) in [#​3812](OPCFoundation/UA-.NETStandard#3812) - Fix Race condition in OnPublishComplete by [@​markuswallen](https://github.com/markuswallen) in [#​3837](OPCFoundation/UA-.NETStandard#3837) - \[master378] Use request.SessionId instead of request.Session.Id in the ReportAuditCancelEvent call from CancelRequests. by [@​mrsuciu](https://github.com/mrsuciu) in [#​3853](OPCFoundation/UA-.NETStandard#3853) - Prune extra decoded children that should stay on the type definition only. by [@​mrsuciu](https://github.com/mrsuciu) in [#​3843](OPCFoundation/UA-.NETStandard#3843) - \[Server] Fix NRE in ActivateSession if Session times out before activation completes by [@​romanett](https://github.com/romanett) in [#​3844](OPCFoundation/UA-.NETStandard#3844) - \[Server] Fix [#​3896](OPCFoundation/UA-.NETStandard#3896): send full certificate chain when CA is in the issuer store (1.5.x) by [@​marcschier](https://github.com/marcschier) in [#​3898](OPCFoundation/UA-.NETStandard#3898) - Synchronize ConditionState branch collection access by [@​marcschier](https://github.com/marcschier) with [@​Copilot](https://github.com/Copilot) in [#​3895](OPCFoundation/UA-.NETStandard#3895) - Prepare 1.5.378 maintenence release by [@​mrsuciu](https://github.com/mrsuciu) in [#​3893](OPCFoundation/UA-.NETStandard#3893) **Full Changelog**: <OPCFoundation/UA-.NETStandard@1.5.378.145...1.5.378.152> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - Between 12:00 AM and 03:59 AM (`* 0-3 * * *`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDIuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI0Mi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://codeberg.org/umati/connect/pulls/21
GoetzGoerisch
pushed a commit
to umati/connect
that referenced
this pull request
Jul 2, 2026
…r to 1.5.378.152 (#22) This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [OPCFoundation.NetStandard.Opc.Ua.Server](https://github.com/OPCFoundation/UA-.NETStandard) | `1.5.378.145` → `1.5.378.152` |  |  | --- ### Release Notes <details> <summary>OPCFoundation/UA-.NETStandard (OPCFoundation.NetStandard.Opc.Ua.Server)</summary> ### [`v1.5.378.152`](https://github.com/OPCFoundation/UA-.NETStandard/releases/tag/1.5.378.152): OPC UA 1.05 Maintenance Update [Compare Source](OPCFoundation/UA-.NETStandard@1.5.378.145...1.5.378.152) Maintenance Release for fixing bugs found on the main378 development branch. #### Released packages [OPCFoundation.NetStandard.Opc.Ua](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Core](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Core/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Security.Certificates](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Security.Certificates/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Configuration](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Configuration/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Server](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Server/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Client](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Client/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.Bindings.Https](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.Bindings.Https/1.5.378.152) [OPCFoundation.NetStandard.Opc.Ua.PubSub](https://www.nuget.org/packages/OPCFoundation.NetStandard.Opc.Ua.PubSub/1.5.378.152) #### What's Changed - Fix memory leak: dispose linked CancellationTokenSource in ChannelAsyncOperation.EndAsync by [@​romanett](https://github.com/romanett) with [@​Copilot](https://github.com/Copilot) in [#​3812](OPCFoundation/UA-.NETStandard#3812) - Fix Race condition in OnPublishComplete by [@​markuswallen](https://github.com/markuswallen) in [#​3837](OPCFoundation/UA-.NETStandard#3837) - \[master378] Use request.SessionId instead of request.Session.Id in the ReportAuditCancelEvent call from CancelRequests. by [@​mrsuciu](https://github.com/mrsuciu) in [#​3853](OPCFoundation/UA-.NETStandard#3853) - Prune extra decoded children that should stay on the type definition only. by [@​mrsuciu](https://github.com/mrsuciu) in [#​3843](OPCFoundation/UA-.NETStandard#3843) - \[Server] Fix NRE in ActivateSession if Session times out before activation completes by [@​romanett](https://github.com/romanett) in [#​3844](OPCFoundation/UA-.NETStandard#3844) - \[Server] Fix [#​3896](OPCFoundation/UA-.NETStandard#3896): send full certificate chain when CA is in the issuer store (1.5.x) by [@​marcschier](https://github.com/marcschier) in [#​3898](OPCFoundation/UA-.NETStandard#3898) - Synchronize ConditionState branch collection access by [@​marcschier](https://github.com/marcschier) with [@​Copilot](https://github.com/Copilot) in [#​3895](OPCFoundation/UA-.NETStandard#3895) - Prepare 1.5.378 maintenence release by [@​mrsuciu](https://github.com/mrsuciu) in [#​3893](OPCFoundation/UA-.NETStandard#3893) **Full Changelog**: <OPCFoundation/UA-.NETStandard@1.5.378.145...1.5.378.152> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - Between 12:00 AM and 03:59 AM (`* 0-3 * * *`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDIuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI0OS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://codeberg.org/umati/connect/pulls/22
This was referenced Jul 4, 2026
Closed
This was referenced Jul 13, 2026
Open
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
On pre-.NET 6 targets (.NET Framework 4.8, netstandard2.1),
ChannelAsyncOperation.EndAsynccreates aCancellationTokenSourceviaCreateLinkedTokenSourcebut never disposes it. The linked registration on the parent token accumulates on every service call that passes a non-defaultCancellationToken, causing gradual memory growth.Typical trigger: any polling loop calling
ReadAsync(or any other service) with a long-livedCancellationToken. Leak becomes noticeable after 1-2 hours of operation.Related Issues
Types of changes
Checklist
Further comments
The
.NET 6+path usesTask.WaitAsync()which doesn't have this issue. Only the#elsefallback path (net48/netstandard2.1) is affected.