2010-05-03 5 views
0

이 로그 내가 얻을, 심지어 오토 릴리즈 풀 현재와 NSThread +detachNewThreadSelector:(SEL)aSelector toTarget:(id)aTarget withObject:(id)anArgument"_NSAutoreleaseNoPool() :"수동 - 양산 스레드 인쇄에 UIGetScreenImage()를 호출 메시지가

 

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    while (doIt) 
    { 
     if (doItForSure) 
     { 
      NSLog(@"checking"); 
      doItForSure = NO; 

      (void)gettimeofday(&start, NULL); 

      /* 
       do some stuff */ 

      // the next line prints "_NSAutoreleaseNoPool():" message to the log 
      CGImageRef screenImage = UIGetScreenImage(); 


      /* 
       do some other stuff */ 

      (void)gettimeofday(&end, NULL); 

      elapsed = ((double)(end.tv_sec) + (double)(end.tv_usec)/1000000) - ((double)(start.tv_sec) + (double)(start.tv_usec)/1000000); 

      NSLog(@"Time elapsed: %e", elapsed); 

      [pool drain]; 
     } 
    } 

    [pool release]; 

에 지정된 선택의 몸

 
2010-05-03 11:39:04.588 ProjectName[763:5903] *** _NSAutoreleaseNoPool(): Object 0x15a2e0 of class NSCFNumber autoreleased with no pool in place - just leaking 

은 다른 사람이 별도의 스레드에 UIGetScreenImage()이를 본 사람 : 나는 UIGetScreenImage()를 호출 할 때이 로그에 인쇄?

답변

0

[pool drain] (iOS에서)은 [pool release]과 동일하게 동작합니다. 따라서 while 회 돌이의 첫 번째 반복 이후에 자동 풀 풀이 필요 없게됩니다. drain을 제거하면 문제가 없습니다. UIGetScreenImage()를 주 스레드가 아닌 다른 스레드에서도 사용할 수 있는지 여부는 확실하지 않습니다.