Re: CoreData huge memory usage - is this right ?
Re: CoreData huge memory usage - is this right ?
- Subject: Re: CoreData huge memory usage - is this right ?
- From: Martin Linklater <email@hidden>
- Date: Tue, 18 Dec 2007 10:57:19 +0000
Perhaps if you'd post your import routine?
Of course... Here are the relevant parts of my code:
Main Controller:
{
NSManagedObjectContext *moc = [appDelegate managedObjectContext];
[moc setStalenessInterval:0.1];
[[moc undoManager] disableUndoRegistration];
[importer importFile:@"AgtOfferDetails.sql"
usingEntity:@"AgtOfferDetails" andFlags:0];
lots more import calls (around 100) etc.
[[moc undoManager] enableUndoRegistration];
}
Import routine:
- (void)importFile:(NSString*)file usingEntity:(NSString*)entity
andFlags:(int)flagsIn;
{
int entryNum = 0;
NSAutoreleasePool* subPool = [[NSAutoreleasePool alloc] init];
while( thisEntry = [filePartsEnum nextObject] )
{
entryNum++;
id coreDataElement = [NSEntityDescription
insertNewObjectForEntityForName:entity inManagedObjectContext:[self
moc]];
// set attributes
[coreDataElement setValue:[NSNumber numberWithInt:[valueString
intValue]] forKey:keyString];
..etc...
if( ( entryNum % 1000 ) == 0)
[subPool drain];
}
}
BOOL ret = [moc save:&error];
if( ret == NO )
{
CPSLogInfo( thisEntry );
[[NSApplication sharedApplication] presentError:error];
}
[subPool release];
}
Sorry for the delay - .Mac was evperiencing problems yesterday ad I
was unable to receive or send email.
Thanks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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