How to reduce main memory usage in cascade deleting large object graphs?

I use Core Data to store lists of data. So, there are parent objects with any number of child objects. Core Data does a great job of preserving my memory when I insert objects and read, but when I do a delete operation, the memory goes up.

When I delete a parent with ~ 5000 children, cascading deletion uses ~ 10 MB. It scales linearly, so one in 10,000 uses 20 MB. As far as I can tell, it reads the entire graphic object in memory before deleting it. I assume this is to ensure data integrity and validity, but I really need to use less memory.

Does anyone know how to get Core Data to use less memory when deleting cascades? Or do I need to cascade manually to reduce memory usage?

+4
source share
1 answer

Now you have to manually cascade if you want to lower the high water mark. Two points:

  • You should file an error message with Apple , requiring more control over the failure behavior during cascading deletion.
  • Have you confirmed that this temporary growth in memory actually causes problems for your application? Of course, you should try to reduce memory usage, but this removal guide may mean that you will lose the opportunity to improve performance in future updates if you do not change your code again.
+1
source

All Articles