Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data memory issue
    text
    copied!<p>I am inserting thousands of data into my SQLite stored Core data . My ManagedObjectContext's undomanager set to nil. I am inserting NSManagedObject in a for loop. tried saving the context in two way, </p> <p>1 after completion of loop (outside the for loop).</p> <pre><code>for(int i =0;i&lt;1000;i++){ MyEntity *object = [NSEntityDescription insertNewObjectForEntityForName:@"MyEntity" inManagedObjectContext:[self managedObjectContext]]; object.name = [NSString stringWithFormat:@"%d",i]; object.age = [NSNumber numberWithInt:i]; } [self managedObjectContext] save:nil]; </code></pre> <p>2 for every insertion (inside the for loop).</p> <pre><code>for(int i =0;i&lt;1000;i++){ MyEntity *object = [NSEntityDescription insertNewObjectForEntityForName:@"MyEntity" inManagedObjectContext:[self managedObjectContext]]; object.name = [NSString stringWithFormat:@"%d",i]; object.age = [NSNumber numberWithInt:i]; [self managedObjectContext] save:nil]; } </code></pre> <p>and finally i called reset for ManagedObjectContext .</p> <pre><code>[[self managedObjectContext] reset]; </code></pre> <p>but the problem is memory taken for this process(insertion) is not get back after the completion.</p> <p>Can any one suggest me whats is wrong with this, or this is the expected behavior ? Any workaround for avoiding this memory leak?</p> <p><strong>UPDATE</strong></p> <p>I tried <code>[[self managedObjectContext] refreshObject:object mergeChanges:NO];</code> It can put back some amount of memory, but not fully.Still searching a good solution for managing large amount of data in <code>CoreData</code>.</p> <p>If any one suggest me an example project(source code) which handle large amount of data in <code>CoreData</code>,then will be helpful for me . Thank You.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload