Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data info & error in console at runtime

I have met the following messages in the console at runtime, and i have no idea why. I have searched everywhere and nobody seems to meet this:

INFO: fetch-response is unable to open the file /Users/userName/Library/Application Support/iPhone Simulator/7.0.3/Applications/964A590B-7131-4BAE-958B-1783BEC193EF/Library/Caches/userName.AppName/fsCachedData/2F1A8708-35A9-491E-9C21-154BA428CA10. Errno: 2

ERROR: failed to mmap cache data from FS: /Users/userName/Library/Application Support/iPhone Simulator/7.0.3/Applications/964A590B-7131-4BAE-958B-1783BEC193EF/Library/Caches/userName.AppName/fsCachedData/83A968D1-0A2B-4D20-97D5-487A876649DC, errno:22

It does not seem to affect the execution though, but I suppose it is not a good sign. I am using Core Data with a timer which frequently updates the database from a server. These messages appear synchronously with the updates, but not systematically. Only one at the time, the "INFO" or the "ERROR". Reset Content and Settings in the Simulator did not solve the problem.

Does anyone have any idea about the meaning of these messages?

like image 375
adauguet Avatar asked Jan 09 '14 21:01

adauguet


People also ask

What is the use of Core Data in iOS?

Overview. Use Core Data to save your application's permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device. To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container.

Is Core Data a database?

Core Data is not a database. Core Data is a framework for managing an object graph. An object graph is nothing more than a collection of interconnected objects. The framework excels at managing complex object graphs.

Where is Core Data saved?

The persistent store should be located in the AppData > Library > Application Support directory. In this example you should see a SQLite database with extension . sqlite. It is possible that you don't see the persistent store in the Application Support directory.


2 Answers

I experienced this when running on my device with an app I am building. It has worked perfect for weeks and then all of a sudden this error. I figured out that it is due to a lack of memory available on the device. I use a little app call "System Status" that allows you to view the memory stats and release any old unused memory. I only get this error in Xcode when I have less than 5% available memory on my device. Therefore it cannot load the cache file the app is request, hence the error. Either close all your multitasking apps and restart your device or get the app and free you memory.

like image 191
Carey Richardson Avatar answered Oct 26 '22 22:10

Carey Richardson


After some testing/debugging (sorry for the delay), I have at least a temporary solution.

Because of the multi-threaded saving process of Core Data, I found it a little tricky to identify the exact error location, but it definitely appears that the error occurs when Core Data is trying to save one of the context in the stack (probably the last "root" one).

As each save take a few seconds (without freezing the UI :p) , I figured the error could be generated by a "save overlap".

So even if I do not have enough to be sure, reducing the save frequency effectively solved my problem: no message anymore in the output.

Now there still is a hitch, and any expert answer would be much appreciated!

like image 44
adauguet Avatar answered Oct 27 '22 00:10

adauguet