인스트루먼트를 사용하면이 코드 조각에 메모리 누수가 발생하여 그 이유를 알 수 없습니다!메모리 누수 NSAutoreleasePool
-(void)goToThisUrl:(id) targetUrl
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (someCondition) {
// Doing some stuff here
}
// Instruments show memory leak on data
else {
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString: targetUrl]];
myTargetImage = [UIImage imageWithData:data];
// When releasing data(because data retainCount = 2), i got:
// Incorrect decrement of the reference count of an object that is not owned at this point by the caller
//[data release];
}
[pool release];
}
감사
분리 된 스레드에 대해이 작업을 수행하고 있습니까? –
예,이 때문에 NSAutoreleasePool을이 메서드에 할당합니다. :) – vince