Coredata performance problem : massive insertion produces error in allocate region
Coredata performance problem : massive insertion produces error in allocate region
- Subject: Coredata performance problem : massive insertion produces error in allocate region
- From: "Kubernan At 10191 Tec." <email@hidden>
- Date: Sun, 11 Mar 2007 10:46:00 +0100
Hello,
I'm new in coredata and i have a big performance problem.
My application inserts in one step about 60 000 instances of an
entity (calling 60 000 times this method):
-(void)insertALine:(NSString *)line
{
countOfInsertedLines++;
NSArray *anArray = [line componentsSeparatedByString:@" "];
NSEntityDescription *entity;
entity = [[[[NSApp delegate] managedObjectModel] entitiesByName]
objectForKey: @"Entity"];
NSManagedObject *obj;
obj = [[NSClassFromString([entity managedObjectClassName]) alloc]
initWithEntity:entity insertIntoManagedObjectContext:[[NSApp
delegate] managedObjectContext]];
[obj setValue:[anArray objectAtIndex:0] forKey:@"val1"];
[obj setValue:[NSNumber numberWithInt:[[anArray objectAtIndex:1]
intValue]] forKey:@"val2"];
[obj setValue:[NSNumber numberWithInt:[[anArray objectAtIndex:2]
intValue]] forKey:@"val3"];
[obj setValue:selectedObject forKey:@"relationship"]; //
selectedObject<-->>Entity relationship
if (countOfInsertedLines > SYNC_CONTEXT_AFTER_MAX_LINE_INSERTED)
{
countOfInsertedLines = 0;
NSError *error;
[[[NSApp delegate] managedObjectContext] save:&error];
}
[obj release];
}
After several minutes, this code produces this error :
malloc: *** vm_allocate(size=81920) failed (error code=3)
malloc: *** error: can't allocate region
malloc: *** set a breakpoint in szone_error to debug
What i'm doing wrong ? What is the best strategy if i want to insert
large amount of instances in small time ? (the persistent store
coordinator uses NSSQLiteStoreType)
Thanks for your help.
K.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden