We have a Xojo (2015.4.1 but I think it happens in later revs) app that occasionally steals 100-200% CPU when idle.
Interestingly it’s after we’ve used drivers to talk to hardware. It continues after we disconnect from the hardware and also for at least 2 different manufacturer’s hardware - so I’m confident it’s not a specific library. I’ve also seen it when connecting over USB or Bluetooth.
Here’s the weird part: when it happens in debugging, I can pause the app in the debugger (often a good way to catch when MY code is going wrong). When the app is paused - none of our code running - the CPU is still pegged at 100-200%. The app appears to run ok but the only way to free up the CPU is to quit the app.
macOS doesn’t appear to make it easy to see which thread in an app is stealing the CPU so it’s tough to dig deeper.
Presumably if the CPU is pegged, there should be some kind of loop running. Sampling the app may give some function names that show what’s happening during the loop and hopefully give you an idea of what it’s doing. You may need to sample a few times to be confident that you know what code is involved in the issue. Whether or not it actually helps you solve the problem, who knows.
I can pause the app entirely, in the debugger, and the CPU is still pegged.
It seems obvious that it’s the libraries causing the problem… I’m just trying to figure out how to figure out what’s causing it and how to avoid the problem…
I have a similar problem with a Windows service. It queries Modbus devices either through USB to RS485 adapters or ethernet to RS485 adapters. When everything is properly set up, everything works fine. If the user installs the software, does not connect any Modbus devices and starts the service, it will take 30%-40% of the CPU. Still trying to track this down.