Re: Garbage collection, core data, and tight loops
Re: Garbage collection, core data, and tight loops
- Subject: Re: Garbage collection, core data, and tight loops
- From: Ben Trumbull <email@hidden>
- Date: Sat, 3 Nov 2007 17:26:05 -0700
Okay, so for completeness, i thought i'd share the resolution of this
with the list, in case someone finds this thread in the future.
I set the app up to create small batches of ManagedObjects (several
hundred at a time) and added a small pause (0.01 sec.) between batches
via a delayed selector.
You shouldn't need a pause, and you should have good results with
batches in the thousands.
Before creating any ManagedObjects, i cancelled undo registration.
Once a batch was created, i processed pending changes, saved, and
reset the managedObjectContext.
incidentally, resetting appears to create a brand new undo manager
for the context, so i disabled each time; there was no need to re-
enable when done.
To disable the undo manager on NSManagedObjectContext, set it to nil.
-reset does not recreate an undo manager.
Using an autorelease pool for each batch worked well, keeping memory
use extremely low.
Using garbage collection resulted in a significant memory gain, but
nowhere near bad enough to crash the program. Oddly, the memory use
did not subside after the loop had finished.
How did you measure that ? 'heap' will provide more useful
information than 'top'
- Ben
_______________________________________________
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