Commit eae41a5
authored
Fix memory leak from undisposed sockets and event handler retention during server restart (#3608)
* Fix memory leak from undisposed sockets and retained event handlers during server restart
When an OPC UA server is stopped and restarted in-process, TcpServerChannel
instances were never garbage collected because UaSCBinaryChannel.Dispose() did
not close the underlying socket. Pending ReceiveAsync operations kept the
channels pinned via SocketAsyncEngine, causing a steady heap growth per cycle.
Changes:
- Close socket in UaSCBinaryChannel.Dispose() to cancel pending async I/O
- Unsubscribe CertificateValidator.CertificateUpdate in StandardServer.Dispose()
- Unsubscribe ConfigurationWatcher.Changed in StandardServer.Dispose()
- Unsubscribe ConnectionStatusChanged from TransportListeners in ServerBase.Dispose()
Verified over 786 restart cycles with stable heap.
* Remove verbose comment
* Remove redundant event unsubscribe before dispose
* Remove duplicate CertificateUpdate unsubscribe (already existed in master)1 parent cff3743 commit eae41a5
File tree
2 files changed
+2
-0
lines changed- Stack/Opc.Ua.Core/Stack
- Server
- Tcp
2 files changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| |||
0 commit comments