-1

Getting SIGABRT due to big number of threads inside my app. I need to log the number of thread running currently inside my iOS app. I don't want to use profiler and breakpoints stuff.

Amar
  • 13,202
  • 7
  • 53
  • 71
dev gr
  • 2,409
  • 1
  • 21
  • 33
  • are you using GCD to create threads? – Bhavesh Oct 23 '13 at 11:40
  • If you pause, using the debugger, you'll be able to see all threads in the debug window. Or do you want to log them while executing? – Andrew Oct 23 '13 at 11:40
  • If you are using XCode 5 then you can see the visual graph of number of threads and load of each thread in Debug Navigator in your XCode. – Bhavesh Oct 23 '13 at 11:45
  • @dev gr This can be due to few other reasons as well. Can you post the crash logs? May be it can give some hint. – Amar Oct 23 '13 at 11:58
  • @Andrew I want to log them while executing. – dev gr Oct 23 '13 at 12:09
  • @Amar my concern is not the error I am getting. But this error is due to creation of large number of threads inside app. – dev gr Oct 23 '13 at 12:11

1 Answers1

1

Try it with this http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_threads.html

    #import <mach/mach_types.h>
    #import <mach/mach_traps.h>
    #import <mach/mach.h>
    thread_act_array_t threads;
    mach_msg_type_number_t thread_count;
    task_t self = mach_task_self();

    /* Get a list of all threads */
    if (task_threads(self, &threads, &thread_count) == KERN_SUCCESS) {
        //thread_count should be populated.
    }

Also you'll have to do some memory management on some of these.

Andrew
  • 3,166
  • 21
  • 32