Reputation: 46310
Problem: I am doing a really big import where I parse an XML file. For every 10 parsed managed objects, I want to save the Managed Object Context and get rid of those 10 objects in memory, so that I have never more than 10 objects in memory at a time.
After saving it, how could I clear the context so that all the objects go away from memory?
Upvotes: 11
Views: 5641
Reputation: 46718
In a situation like this there are four things to remember to do:
NSAutoreleasePool
This will flush all of the memory being used and clear the context.
Upvotes: 26