I try to reproduce a crash cause by wakeups limit exceed, sample code below:
for (int i = 0; i < 500; i++) {
NSThread *thread = [[NSThread alloc] initWithBlock:^{
[[NSThread currentThread] setName:[NSString stringWithFormat:@"%d", i]];
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
[runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];
CADisplayLink *link4 = [CADisplayLink displayLinkWithTarget:self selector:@selector(threadCadisplayLink)];
// link4.frameInterval = 60;
[link4 addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[runLoop run];
}];
[thread start];
}
- (void)threadCadisplayLink {
NSInteger index = arc4random()%100;
NSObject *obj = [NSObject new];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
self.info[@(index)] = obj;
});
}
I get wake up times every second:
static NSInteger old_interrupt_wakeup;
static NSInteger old_timer_wakeup;
static NSInteger old_idle_wakeup;
[NSTimer scheduledTimerWithTimeInterval:1 repeats:true block:^(NSTimer * _Nonnull timer) {
NSInteger interrupt_wakeup;
NSInteger timer_wakeup;
NSInteger idle_wakeup;
rm_system_wakeup(&interrupt_wakeup, &timer_wakeup, &idle_wakeup);
NSLog(@"interrupt_wakeup: %ld timer_wakeup:%ld idle_wakeup: %ld", interrupt_wakeup - old_interrupt_wakeup, timer_wakeup - old_timer_wakeup, idle_wakeup - old_idle_wakeup);
old_interrupt_wakeup = interrupt_wakeup;
old_timer_wakeup = timer_wakeup;
old_idle_wakeup = idle_wakeup;
}];
rm_system_wakeup is same as @Daniel-Duan said
I get interrupt_wakeup about 300000 every second, but fail to get Demo app crash.
2023-01-17 13:48:42.576934+0800 Demo[44926:1519725] interrupt_wakeup: 29684 timer_wakeup:5 idle_wakeup: 0
2023-01-17 13:48:43.577225+0800 Demo[44926:1519725] interrupt_wakeup: 30008 timer_wakeup:5 idle_wakeup: 10780509616
2023-01-17 13:48:44.577003+0800 Demo[44926:1519725] interrupt_wakeup: 30006 timer_wakeup:4 idle_wakeup: 0
2023-01-17 13:48:45.577459+0800 Demo[44926:1519725] interrupt_wakeup: 29505 timer_wakeup:3 idle_wakeup: 0
2023-01-17 13:48:46.577329+0800 Demo[44926:1519725] interrupt_wakeup: 30004 timer_wakeup:2 idle_wakeup: 0
Another question is what the difference between Crash with WAKEUPS subtype and wakeup event with a wakeups_resource-xxx.ips file, is wakeups_resource-xxx.ips means a crash happened?