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: "I. Savant" <email@hidden>
- Date: Fri, 14 Dec 2007 10:10:51 -0500
> You can check the [NSManagedObjectContext setStalenessInterval:] documentation, disable the undoManager, read the http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdMemory.html#//apple_ref/doc/uid/TP40001860 and use a NSAutoreleasePool, even under GC (remember to use drain instead of release).
Winner. :-)
Core Data or not, creating many objects in a tight loop (regardless
of saving a file in the middle of it) never gives autoreleased objects
a chance to be released. Since the
-insertNewObjectForEntityForName:inManagedObjectContext: method
returns an autoreleased object, the thousands of objects you're
creating aren't going away until (likely) the end of your import.
As suggested above, create an autorelease pool prior to entering
your loop. Every thousand, you don't need to save, but you do need to
-drain the pool. This will effectively cap the memory usage in the
scenario you described.
--
I.S.
_______________________________________________
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