• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Coredata performance problem : massive insertion produces error in allocate region
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Coredata performance problem : massive insertion produces error in allocate region
      • From: "Philip Q" <email@hidden>
    • Re: Coredata performance problem : massive insertion produces error in allocate region
      • From: Julio Cesar Silva dos Santos <email@hidden>
  • Prev by Date: Re: NSImage - newbie
  • Next by Date: Re: Framework project config & accessing resources in the framework bundle.
  • Previous by thread: Re: NSImage - newbie
  • Next by thread: Re: Coredata performance problem : massive insertion produces error in allocate region
  • Index(es):
    • Date
    • Thread