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.
anyone seen this?
Use activity monitor app to analyze app.
Probably the libraries useful threads polling devices in background.
what can I see in the activity monitor that will help diagnose this?
Activity Monitor app is in /Applications/Utilities folder.
The menu has an Analyze command.
not to be too pedantic but mine doesn’t (Sierra)
I can click the (i) button and see some details but I can’t get it to break out the threads
Perhaps you mean Sample Process under the gear menu? I can do that but I can’t seem to get thread CPU info that I understand.
perhaps I’m missing something…
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.
Thanks Kevin but that’s the weird thing.
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…
it’s a fun one
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.
sorry Kevin, I re-read your post and just realized that you meant to sample it in Activity Monitor. duh.
I’ll give that a try