저를 도와 준 사람에게 미리 감사드립니다.CFRunLoopRun() 및 NSTimer -> 세분화 오류
나는 간단한 데몬을 가졌다. 나는 클래스를 할당하고 NSTimer 반복 예약 &을 시작 : 내 데몬이 살아있을 수 있도록
[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(usage3GviaSysctl) userInfo:nil repeats:YES];
다음 내가 CFRunLoopRun()를 호출합니다.
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
signal(SIGTERM, (sig_t)SIGTERM_handler);
helper = [[NMDaemonHelper alloc] init];
[helper startNotificationServer];
CFRunLoopRun();
NSLog(@"NMDAEMON: will exit");
[pool release];
return 0;
}
이제 문제는 타이머 화재 후 나는 세그먼트 폴트를 얻을 수 있다는 것입니다. BT : 중 하나가 작동하지 않았다 타이머를 시작하는
objc_msgSend
__NSFireTimer
__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
__CFRunLoopDoTImer
__CFRunLoopRun
CFRunLoopRunSpecific
다른 방법. 예 :
NSTimer *timeUpdateTimer = [[NSTimer alloc] initWithFireDate:[NSDate date] interval:1 target:self selector:@selector(usage3GviaSysctl) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timeUpdateTimer forMode:NSDefaultRunLoopMode];
아무도 아이디어가 있습니까 (wr)? (g)?
참고 : 'dealloc'은 호출되지 않습니다. _ [Using Timers : Memory Management] (http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Timers/Articles/usingTimers)를 참조하십시오. .html # // apple_ref/doc/uid/20000807-SW6) _. – danyowdee
도와 주셔서 감사합니다. 사실, NSTimer로 인해 발생하지는 않지만 타이머의 action 메소드에서 sysctl을 사용했기 때문에 발생하는 것으로 나타났습니다. 이것은 크래시 기자가 잘못된 bt를 만들 것이기 때문에 식별 할 수있는 것이 아니 었습니다. ( – YllierDev
@danyowdee, dealloc이 이것을 완벽하게 구현했습니다. 이것은 고의적 인 예제이지만 실제 클래스를 사용한다면 – pho0