어떻게 내가 autoreleasepool {} 외부에서 생성 된 내 오토 릴리즈 객체를 해제하는 autoreleasepool을 강제 할 수 내부에 오토 릴리즈 객체를 생성자료는 외부 autoreleasepool {}
-1
A
답변
3
을 필요가 있다고 생각합니다. 하지만 여기서 잘못된 문제를 해결하려고하는 것처럼 보입니다. _updates
을 실제로 의미하는 경우 메서드에 의한 것이 아니라 호출자에 의한 메모리 관리가되어야합니다 (이미! JSONObjectWithData:options:error:
은 이미 자동으로 릴리즈 된 인스턴스를 반환합니다). updates
을 의미하는 경우 단순히 유지하지 마십시오.
0
불가능합니다. 난 당신이 오토 릴리즈 풀의 범위, 즉 자동으로 풀에 오브젝트를 추가 할 때 간단하게 autorelease
를 호출이
- (void)connectionDidFinishLoading:(NSURLConnection *)theConnection {
@autoreleasepool {
NSError *error = nil;
id response = [NSJSONSerialization JSONObjectWithData:responseData options:nil error:&error];
[responseData release];
if (error) {
NSLog(@"ERROR JSON PARSING : %@", error.localizedDescription);
}
[delegate databaseUpdates:response connection:self];
} // response will be released here
}
감사합니다. autoreleasepool {_} 내부의 _updates에서 autorelease를 호출하려고합니다. – user1839842
@ user1839842 : 아니요, JustSid는'release' 또는'autorelease''_updates'를 사용해서는 안됩니다. 당신은 그 범위에 남아 있지 않은 것들을 공개하지 않습니다. – newacct
내 메모리 경고 문제를 줄이는 또 다른 방법을 찾았습니다. 나는 databaseUpdates : 메소드에서 autoreleasepool을 삭제했다. _updates 오브젝트는 databaseUpdates : 메소드 끝에서 제거됩니다. 당신의 도움을 주셔서 감사합니다! – user1839842