Home / IOS Development / ios – Core data: "Allows external storage" performance on large files

ios – Core data: "Allows external storage" performance on large files

I'm trying to understand the behavior of Allows external storage properties to Core Data attributes and see if it will save me from manually storing files in the file system. I wanted to see how it would work when I was handling really large files. For that, I created a dummy project and saved a large file (2 GB) using Core Data. Then I monitored memory usage while retrieving and processing the data, and to my surprise they did not exceed 48 MB! Why? Does it capture the data in bits? If so, how? Does Data structure APIs that allow core data to do that?

More details about what I did:

  1. Created a device File with only two attributes, filename (String) and data (Data).
  2. Checked Allows external storage for the attribute data .
  3. Stored a 2 GB file in the device File .
  4. Retrieved the big file's data.
  5. Loops through the data, byte byte, read and XORing them.
  6. Monitored memory usage. [1
    9659009] I'm pretty sure it has something to do with Core Data and not Data since I did the same steps when loading data from disk ( Data (contentOf: URL) ) will result in 3+ GB of memory usage (also, why the extra 1 GB?).

    Finally, is there any reason not to use Does external storage feature allow tead to manually store files in the file system? I know that this issue has been much discussed; but most of the points I read that suggest using the manual way were to mention performance issues with Core Data, even though my little experiment shows that Core Data is performing well.

    Any help will be appreciated!

Source link