Hi alt,
We discovered a memory leak in our production environment. Memory grows from ~2GB to 3.6GB over one week and never releases.
Environment:
- Inetlab.SMPP version: 2.9.35
- .NET 8
- Linux
Memory profiler shows DiagNode<ActivityEvent> objects accumulating: see image1.jpeg
Memory growth over time: see image2.jpeg
Root Cause Analysis:
Found issue in SmppSession.cs - Activity objects not disposed for throttled requests.
Line 960 - throttled path:
_ = SendResponseAndDelayedRequests(resp, null, activity, _cancellationTokenSource.Token);
Activity is created at line 933 but SendResponseAndDelayedRequests never disposes it. Only HandleReceivedRequest disposes activity at line 718, but throttled requests bypass this method.
Suggested Fix:
Add activity?.Dispose() in SendResponseAndDelayedRequests or wrap throttled call:
// Option 1: Dispose after fire-and-forget completes
_ = SendResponseAndDelayedRequests(resp, null, activity, _cancellationTokenSource.Token)
.ContinueWith(_ => activity?.Dispose());
// Option 2: Add try-finally in SendResponseAndDelayedRequests
Can you please review and confirm?
Thank you.
Memory Leak - Activity objects not disposed in SmppSession.cs
Memory Leak - Activity objects not disposed in SmppSession.cs
- Attachments
-
- image2.jpg (219.09 KiB) Viewed 29 times
-
- image1.jpeg (234.2 KiB) Viewed 29 times