Provide example for why it is not advisable to store images in CoreData?

前端 未结 3 1396
温柔的废话
温柔的废话 2021-01-07 14:48

this question has been asked many times, I have read many users telling that it is not advisable to store images in a DB, in particular within CoreData. By they all seems to

3条回答
  •  执笔经年
    2021-01-07 15:40

    Leonardo,

    With Lion/iOS 5, Core Data started handling file system storage of large BLOBs for you.

    The choice is really determined by how many images you are going to have open. If you have many, then you should keep them in the DB. Why? Because you only have a modest number of file descriptors, one of which is used for each open image stored in the file system.

    That said, there is still a reason to manage the files yourself. If your BLOBs are really big, say 2+ MB, you will want to map them into memory and not just read them in. (When the memory warnings come, this lets the OS automatically purge them from your resident memory. This is a very good thing.) Even so, you still have the limited number of file descriptors problem.

    Andrew

提交回复
热议问题