2011-08-05 2 views
0

나는 다음과 같은 두 가지 방법이있어 :IOS : 누출 경고 명확하지

-(void)playSound { 
    NSString* filePath = [self getBasePath]; // <-- warnings appear when this is called 
} 

-(NSString*) getBasePath { 
    if(debug) NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__); 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); 
     NSString *documentsDir = [paths objectAtIndex:0]; 

    if(debug) NSLog(@">>> Leaving %s <<<", __PRETTY_FUNCTION__); 
    return documentsDir; 
} 

호출시 소리가 메도 getBasePath가 호출됩니다. 하지만 콘솔에 다음 경고가 표시됩니다.

2011-08-06 00:26:56.298 Alarm[82648:5d03] *** __NSAutoreleaseNoPool(): Object 0x4e350e0 of class __NSArrayM autoreleased with no pool in place - just leaking 
2011-08-06 00:26:56.299 Alarm[82648:5d03] *** __NSAutoreleaseNoPool(): Object 0x4e350c0 of class NSCFString autoreleased with no pool in place - just leaking 
2011-08-06 00:26:56.300 Alarm[82648:5d03] *** __NSAutoreleaseNoPool(): Object 0x4b43c00 of class NSCFString autoreleased with no pool in place - just leaking 
2011-08-06 00:26:56.300 Alarm[82648:5d03] *** __NSAutoreleaseNoPool(): Object 0x4b46900 of class NSPathStore2 autoreleased with no pool in place - just leaking 
2011-08-06 00:26:56.301 Alarm[82648:5d03] *** __NSAutoreleaseNoPool(): Object 0x4e37630 of class NSPathStore2 autoreleased with no pool in place - just leaking 
2011-08-06 00:26:56.302 Alarm[82648:5d03] *** __NSAutoreleaseNoPool(): Object 0x4e35100 of class __NSArrayI autoreleased with no pool in place - just leaking 

그 의미는 무엇입니까?

답변

3

아마도이 메서드는 주 스레드가 아니라 실행 중일 것입니다. 그럴 경우 NSAutoreleasePool을 만들어야합니다.

-(void)playSound { 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    int index = rand() % [soundFilenames count]; 
    NSString* filePath = [self getBasePath]; 
    [pool drain]; 
} 
+0

감사합니다. 사실 그렇습니다. – toom