큰 데이터 세트 (~ 6,000)를 핵심 데이터 응용 프로그램으로 가져 오려고합니다. Apple 문서 "효율적으로 데이터 가져 오기"를 읽었으며 제대로 설정했다고 생각합니다. 이상한 일은 시뮬레이터에서 응용 프로그램이 충돌하지 않는 것입니다. 누출 도구로 실행해도 문제가되지 않지만 모든 데이터가 저장되지는 않습니다. 때로는 3 ~ 4 백 번을 절약 할 수 있으며, 3 ~ 4 천 건이 저장되며 전체 데이터 세트는 거의 저장되지 않습니다. 나는 아마도 메모리 누수와 관련이 있다고 생각하고 NSAutoReleasePool을 사용하는 것에 대해 매우 익숙하다.핵심 데이터 가져 오기 실패
NSURL *url = [NSURL URLWithString:@""];
NSString *responseString = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:nil];
if (responseString) {
NSArray *players = [responseString componentsSeparatedByString:@";"];
NSUInteger LOOP_LIMIT = 100, count = 0;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSManagedObjectContext *context = [[AppController sharedAppController] managedObjectContext];
[context setUndoManager:nil];
for (int i=0; i<([players count] - 1); i++) {
NSArray *info = [[players objectAtIndex:i] componentsSeparatedByString:@","];
NSString *dateInfo = [info objectAtIndex:10];
NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
NSDateFormatter *fo = [[[NSDateFormatter alloc] init] autorelease];
[fo setDateFormat:@"MM/dd/yyyy"];
[fo setLocale:usLocale];
[fo setTimeZone:[NSTimeZone systemTimeZone]];
NSDate *dob = [fo dateFromString:dateInfo];
Players *player = [NSEntityDescription insertNewObjectForEntityForName:@"Players"
inManagedObjectContext:context];
NSNumberFormatter *f = [[[NSNumberFormatter alloc] init] autorelease];
[f setNumberStyle:NSNumberFormatterNoStyle];
player.playerID = [f numberFromString:[info objectAtIndex:0]];
player.lastName = [info objectAtIndex:1];
player.firstName = [info objectAtIndex:2];
player.position = [info objectAtIndex:4];
NSString *teamName = [info objectAtIndex:3];
NSFetchRequest *req = [[[NSFetchRequest alloc] init] autorelease];
NSEntityDescription *ent = [NSEntityDescription entityForName:@"Teams" inManagedObjectContext:context];
[req setEntity:ent];
[req setIncludesPropertyValues:NO];
NSPredicate *pre = [NSPredicate predicateWithFormat:@"team=%@", teamName];
[req setPredicate:pre];
NSArray *list = [context executeFetchRequest:req error:nil];
if ([list count]) {
Teams *team = [list objectAtIndex:0];
player.team_Players_Teams = team;
}
count++;
if (count == LOOP_LIMIT) {
[context save:nil];
[context reset];
[pool drain];
pool = [[NSAutoreleasePool alloc] init];
count = 0;
}
}
if (count != 0) {
NSLog(@"In Save Remaining");
[context save:nil];
[context reset];[pool drain];
}
내가 어떤 명백한 누수 만 볼 수
끝에 [풀 배수구]가 누락되었습니다. – Felix
True - 방금 추가했으나 실제 가져 오기에는 영향을 미치지 않습니다. 아직 가져 오기 과정에서 약간의 오류가 있어야합니다. – nlutterman