0
계측기를 실행할 때 힙이 증가하는 것을 눈치 채고 있습니다. 누수가 없지만 핵심 데이터를 사용하여 발생하는 것으로 보이는 메모리가 삭제되지 않습니다. 스택에서 핵심 데이터 관리 대상 개체와 관련된 힙 성장 중지
을 추적 내가 관리 객체를 저장할 때 성장이 일어나는 것 같다.이것은 내가 관리 객체를 만드는거야 방법입니다
ScramblerGame *game = (ScramblerGame *)[NSEntityDescription insertNewObjectForEntityForName:@"ScramblerGame" inManagedObjectContext:self.context];
game.time = [NSNumber numberWithInt:self.time];
game.score = 0; //etc...
ScramblerGame없이 수정을 데이터 모델에서 바로 만들어 관리되는 개체의 하위 클래스입니다.
self.game.score = [NSNumber numberWithInt:[self.game.score intValue] + score];
self.game
관리되는 개체에 대한 다른 클래스에 약한 참조입니다 :
이 내가 액세스하고 관리되는 개체를 통해 업데이트하는 방법입니다.
데이터를 저장하거나 삭제하는 게임의 끝에서 호출되는 메서드입니다. 또한 참조 된 이미지의 스택 추적에서 호출 된 마지막 메서드이기 때문에 힙이 커집니다.
-(void)saveAndHandleGameData:(BOOL)stillPlaying{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextObjectsDidChangeNotification object:nil];
//save the data to disk
self.game.inProgress = [NSNumber numberWithBool:stillPlaying];
SCAppDelegate *appDelegate = ((SCAppDelegate *)[[UIApplication sharedApplication] delegate]);
NSManagedObjectContext *context = appDelegate.managedObjectContext;
if([self.game.score intValue] == 0)
[context deleteObject:self.game];
[context save:nil];
self.game = nil;
}
이렇게 나는 원인이되는 핵심 데이터에 문제가 있습니까? 힙 증가를 막는 방법에 대한 조언은 무엇입니까?