ios - Memory increasing every core data iteration -
having memory issue while iterating through core data objects. loops through cfdata (store) keeps increasing until application crashes. shouldn't core data release memory after every loop finishes?
for (patient *patient in self.fetchedresultscontroller.fetchedobjects) { (exam *examforpatient in patient.exams) { //do stuff examforpatient } }
edit - tried following , still behaving same way:
for (patient *patient in self.fetchedresultscontroller.fetchedobjects) { (exam *examforpatient in patient.exams) { nslog(@"%@", [examforpatient.examdate description]); [self.fetchedresultscontroller.managedobjectcontext refreshobject:examforpatient mergechanges:no]; } [self.fetchedresultscontroller.managedobjectcontext refreshobject:patient mergechanges:no]; }
when no longer have need item reside in memory, can refresh it.
docs:
"if iterate on lot of objects, may need use local autorelease pool blocks ensure temporary objects deallocated possible"
edit: see @lnafziger answer
note: if updating patient object or exam objects, cannot refresh loose changes (if use mergechanges:yes
not release memory). need save periodically , refresh objects no longer need.
see here more information.
Comments
Post a Comment