Residual Set Issue / Performance Using Multiplie MOCs

This is the first time I have used the new version of RestKit and a few MOCs, so it was a little shaky. I use RestKit 0.20-pre5 and add Managed Objects through RestKit operations, as well as manually throughout the application.

RestKits provides two MOCs for performance management: mainQueue and PersistantStore contexts. When checking the RestKits code, all new managed objects are saved in the mainQueue MOC (based on line 433 of the RKObjectManager and checking various pointer addresses). The objects created by RestKit are saved in order (after calling save the course), however, whenever I create my own ManagedObjects in the same mainQueue MOC and save it, they are not saved when I restart the application. (I often keep the corresponding MOC)

Here is a permanent store. When I save a persistent store along with the mainQueue MOC, the data is saved. I assume this has something to do with RKManagedObjectStore changes when I call save on persistantStoreMOC (via notification). So ... is everything alright?

The problem is that when I save both contexts, there is a noticeable lag that lasts at least 1 second (it can vary up to 3!). This lag seems to increase the number of NSManagedObjects created. I have tools and there are no memory problems. I have to use RestKits to implement the underlying data incorrectly.

For the record I save using the following method:

- (void)saveContext { __block BOOL _blockSuccess; __block NSError *_blockError; NSManagedObjectContext *persistantContext = [[[RKObjectManager sharedManager] managedObjectStore] persistentStoreManagedObjectContext]; [globalManagedObjectContext performBlockAndWait:^{ _blockSuccess = [globalManagedObjectContext save:&_blockError]; }]; if (! _blockSuccess) NSLog(@"Failed to save context: %@", _blockError); [persistantContext performBlock:^{ _blockSuccess = [persistantContext save:&_blockError]; if (! _blockSuccess) NSLog(@"Failed to save context: %@", _blockError); }]; } 

It is called from the singleton object whenever we want to save the state of the application. (globalManagedObjectContext is just a macro pointing to RestKits mainQueueObjectContext). Removing persistence persistantContext saves the delay, but of course does not save the data.

Any help (especially Blake Watters;) would be greatly appreciated!

Greetings

Aron

+1
source share
1 answer

I believe the answer is to use the saveToPersistentStore: method, added by the RKAdditions category, in NSManagedObjectContext.

It is taken from here and here .

Do you still have problems using this?

+1
source

All Articles