Core Data memory usage and Memory Warning

前端 未结 2 672
时光取名叫无心
时光取名叫无心 2020-12-25 08:30

I have this issue. I have a database of images in Core Data. I fetch all images (about 80MB) and put in an NSMutableArray. The objects are correctly faulted:



        
2条回答
  •  Happy的楠姐
    2020-12-25 09:23

    I think you should load the less objects into memory in batch.

    memory released by coredata happens behind the scenes and you don't have to program for it; the bad news is that it happens behind the scenes and thus can 'magically' chew up memory.

    Ways around it are many; for example, use a predicate to only select the rows you absolutely must need; don't do a general call to fetch everything and then go through the list one by one. More than likely you will crash when you do the general call and CoreData attempts to load all objects.

提交回复
热议问题