Why is my iOS 7 app running at 100 percent CPU utilization after some time?

My iOS 7 app works great in the beginning. Without user interaction, the processor load returns to 0%.

Then, after some time of using it, the processor load suddenly rises to 100% and stays there.

The tools show a threat called _pthread_tsd_cleanup (libsystem_pthread.dylib).

I tried to find more information about this, but I still have no solution.

Tool Call Tree:

Running Time    Self        Symbol Name
   653458.0ms   99.9%   0.0     _pthread_tsd_cleanup  0x6a712
   653458.0ms   99.9%   0.0      _pthread_wqthread
   653458.0ms   99.9%   0.0       _pthread_exit
   653458.0ms   99.9%   0.0        _pthread_tsd_cleanup
   653458.0ms   99.9%   0.0         FreeContextStack
   594802.0ms   91.0%   52562.0          PopContext
   366935.0ms   56.1%   25844.0           GetContextStack
   260166.0ms   39.8%   99324.0            GetContextStack
   160842.0ms   24.6%   160842.0                pthread_once
   41188.0ms    6.3%    41188.0            pthread_getspecific
   39737.0ms    6.0%    39737.0            pthread_once
   157048.0ms   24.0%   87958.0           PopContext
   69090.0ms   10.5%    69090.0            GetContextStack
   15386.0ms    2.3%    15386.0           DYLD-STUB$$pthread_once
   2871.0ms    0.4% 2871.0            DYLD-STUB$$pthread_getspecific
   58656.0ms    8.9%    24503.0          FreeContextStack
   34153.0ms    5.2%    34153.0           PopContext
   143.0ms    0.0%  0.0     Main Thread  0x6a6e9
   3.0ms    0.0%    0.0     _dispatch_worker_thread2  0x6ac4e
   2.0ms    0.0%    0.0     _dispatch_worker_thread2  0x6b020
   1.0ms    0.0%    0.0     _pthread_tsd_cleanup  0x6ae2a
   1.0ms    0.0%    0.0     _dispatch_worker_thread2  0x6b2b9
   1.0ms    0.0%    0.0     _dispatch_mgr_thread  0x6a710
   1.0ms    0.0%    0.0     start_wqthread  0x6af42
   1.0ms    0.0%    0.0     _dispatch_worker_thread2  0x6b195
   1.0ms    0.0%    0.0     _dispatch_worker_thread2  0x6b0c1
+4
source share
2 answers

I myself found the answer by commenting on different parts of my code, until I could determine the part of my code that caused this behavior.

, .

UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale);
CGContextRef context = UIGraphicsGetCurrentContext();
[color setFill];
CGContextTranslateCTM(context, 0, image.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextClipToMask(context, CGRectMake(0, 0, image.size.width, image.size.height), [image CGImage]);
CGContextFillRect(context, CGRectMake(0, 0, image.size.width, image.size.height));
+4

, , UIGraphicsBeginImageContextWithOptions(...) UIGraphicsEndImageContext().

+10

Source: https://habr.com/ru/post/1534087/


All Articles