Abhinav
Abhinav

Reputation: 38162

Application hangs when profiling with instrument in Xcode 6.0.1

I am observing that whenever I am profiling my application using instrument in Xcode 6.0.1, application hangs every time while I am browsing through the application. I am using iPhone 5S (iOS 8.0.2) to run my application. When I run the application on device it runs all fine.

Upvotes: 12

Views: 5262

Answers (4)

sig
sig

Reputation: 6054

Follow those steps:

  1. Run app on your device. It would be better if you set Release build in Edit scheme menu.
  2. Go to the Debug navigator section on your Navigator (left menu in Xcode).
  3. Click on CPU.
  4. Click on Profile in Instruments and choose Transfer.
  5. Instruments will run Time Profiler. Then in top panel click on Library button (looks like "+").
  6. The library menu will open. You need to select your instrument.

Upvotes: 1

Oscar Hierro
Oscar Hierro

Reputation: 1107

Extending on Abhinav's correct answer, NSLog() is indeed triggering the issue, but not all NSLogs, only some very large ones. In my case I was logging some long responses from a web service, and commenting only those ones out fixed the problem of Instruments hanging. I guess this is the reason why the issue is not as widespread as you'd think (I couldn't find any reference to it on Apple's dev forums).

Upvotes: 2

Zoltán
Zoltán

Reputation: 1450

I've just been solving the same issue and it turned out to be caused by something else. I'm not 100% sure yet which part of my code is responsible, but it's got something to do with accessing the internet. So I've switched into Airplane mode et voila! So my conclusion is that a network request was hanging the main thread (only when running Instruments tho -- weird) and if anyone else is running into similar problems, try finding what might hang your main thread.

Hope it saves some time :)

Z.

Upvotes: 1

Abhinav
Abhinav

Reputation: 38162

Found the fix - disabling the NSLog statements (profiling on release and not on debug) solved the issue for me.

Upvotes: 17

Related Questions