C# MQTT Client CPU spikes at exactly 20 minutes - how do you troubleshoot this in Visual Studio?

Viewed 231

I am using the M2mqtt Nuget package to create an MQTT client that connects to AWS IoT core. The client works perfectly, for exactly 20 minutes. In the first 20 minutes, the process consistently utilises 15MB memory and very few CPU cycles (Task Manager shows 0% - 0.5%). Then exactly on the 20 minute marker, it jumps to 15% - 25% CPU and just stays there permanently as though it's stuck in a nasty loop.

This is my first C# .NET project (It's actually my first desktop development project), and I'm not sure how to pin down the issue. I found the debugging tools in Visual Studio 2019 and managed to record this, but I can't make much sense of it. My C# program is basically this: https://github.com/aws-samples/iot-dotnet-publisher-consumer/blob/master/Dotnetsamples/Iotconsumer/Iotconsumer/Program.cs

Does the debugging screenshot below explicitly mean that 93% of the total clock time, during the performance profiling period, was used by ReceiveThread(), specifically line 1362? If so - why would such a thing start exactly after 20 minutes of otherwise faultless activity (where a full execution cycle is 15 seconds)?

Does this behaviour typically point to a timeout or keep alive issue?

enter image description here

enter image description here

0 Answers
Related