Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS CPU Profile: Why might this thread be sucking up 99.9% CPU?

Sometimes when I load a table view, and I'm performing no activity intentionally except letting the table view show, I'll wait a few seconds and then my CPU usage shoots up. How can I find the cause?

enter image description here

like image 958
Rose Perrone Avatar asked Jul 24 '14 17:07

Rose Perrone


2 Answers

Its possible you're not ending your UIGraphicsBeginImageContext

I solved the same by adding UIGraphicsEndImageContext after use.

like image 190
Rudi Avatar answered Mar 18 '23 06:03

Rudi


Why might this thread be sucking up 99.9% CPU?

I don't know. But here are some thoughts:

  1. The responsible library is UIKit. So it seems that some user interface code is broken.
  2. A function named FreeContextStack is running for a long time.
  3. pthread_once and pthread_getspecific take a considerable amount of time. These functions are fast, so they have to run very often.
  4. They are part of GetContextStack and PopContext

It seems that in your code there is some sort of "context" stack being pushed—but not popped. I'd look for occurrences of UIGraphicsPushContext or UIGraphicsBeginImageContext without their closing counterparts.

But I might be totally off and those functions are not part of graphics context code.

like image 26
Nikolai Ruhe Avatar answered Mar 18 '23 07:03

Nikolai Ruhe