Skip navigation.
 
mlRe: Garbage collection, core data, and tight loops
FROM : Ben Trumbull
DATE : Sun Nov 04 01:26:05 2007

> 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

Related mailsAuthorDate
mlGarbage collection, core data, and tight loops John R.Timmer Oct 30, 22:03
mlRe: Garbage collection, core data, and tight loops Bill Bumgarner Oct 30, 22:56
mlRe: Garbage collection, core data, and tight loops John R. Timmer Oct 31, 13:37
mlRe: Garbage collection, core data, and tight loops Bill Bumgarner Oct 31, 16:31
mlRe: Garbage collection, core data, and tight loops Ben Trumbull Nov 1, 03:41
mlRe: Garbage collection, core data, and tight loops John R. Timmer Nov 2, 20:01
mlRe: Garbage collection, core data, and tight loops Ben Trumbull Nov 4, 01:26
mlRe: Garbage collection, core data, and tight loops Chris Hanson Nov 4, 02:59
mlRe: Garbage collection, core data, and tight loops John R. Timmer Nov 4, 05:06