내 스레드를 잠시 실행 한 후에 Instruments는 __NSDate가 지속적으로 # 살아있는 값을 받음을 보여줍니다.스레드의 iOS 메모리 누수
내 결론은이 트레드가 객체를 배제하지 않는다는 것입니다. 그러나이 줄은 컴파일 오류를 발생시킵니다. NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
이 스레드가 모든 객체를 유지하도록하려면 어떻게해야합니까? 아니면 어떻게 ARC가 작동하는 적절한 스레드를 만들어야합니까?
- (void) start {
NSThread* myThread = [[NSThread alloc] initWithTarget:self
selector:@selector(myThreadMainRoutine)
object:nil];
[myThread start]; // Actually create the thread
}
- (void)myThreadMainRoutine {
// stuff inits here ...
// Do thread work here.
while (_live) {
// do some stuff ...
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
[NSThread sleepForTimeInterval:0.05f];
}
// clean stuff here ...
}
감사가? – michael
@michael : 나의 마지막 코멘트는 실제로 잘못되었습니다. 두 개의 수영장이 필요합니다. 그에 따라 대답을 업데이트했습니다. –