Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove CoreData's objects from memory?

I use CoreData to store image data that user took from iPhone's Camera. Over time, the memory consumed by these objects keep increasing, but I don't know how to clear those objects from the memory.

How should this be done?

like image 720
Boon Avatar asked Feb 15 '26 19:02

Boon


1 Answers

You can tell the managedObjectContext to retain or not retain objects (in addition to the ones you retain) with:

[managedObjectContext setRetainsRegisteredObjects:YES];

See http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/index.html?http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html for a discussion of what this does.

Note that you also have to be careful not to retain and leak the objects yourself, or this will have no effect.

-Wil

like image 166
Wil Shipley Avatar answered Feb 17 '26 10:02

Wil Shipley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!