Re: Core Data Performance w/ long list
Re: Core Data Performance w/ long list
- Subject: Re: Core Data Performance w/ long list
- From: Matt Ronge <email@hidden>
- Date: Thu, 29 Dec 2005 10:41:58 -0600
Jeff LaMarche wrote:
At the point where the list is done downloading (in a thread) and I
save the context (on the main thread because it seems to crash if I
do it in the thread), the UI freezes for a significant period of time
- 30 seconds or more. I've experimented with changing the store type
with no appreciable difference. I've also tried doing periodic saves
to the context that stores the server information, which helps some,
but the final save (after I insert the objects into the Server's to-
many relationship) is still horrible, and if I insert them into the
relationship as I create them, then the interface bogs down horribly
and the user can't do anything at all if the groups list is visible.
I am doing something very similiar with a mail client I am working on. I
have the primary gui thread and which launches a background worker
thread that downloads data from the mail server. For each folder I
download all of the messages and then save to the ManagedObjectContext.
Now the trick here is to have seperate ManagedObjectContexts for each
thread that share the same NSPersistanceStoreCoordinator, however your
going to have to notify the main thread that it has to refresh it's
objects from the NSPersistanceStoreCoordinator into it's own
managedobjectcontext. What I've done, is I catch the didSave
notification that is sent out from the managedobjectcontext in the
workerthread and handle it inside the workerthread. The notification
contains a list of objects ID's that have been saved so I send that to
the main thread and refresh those objects.
Performance hasn't been a problem for me so far using this method.
I've also found that periodic saves have improved performance for me,
and with the workerthread in the background the interface is partially
populated.
Hope that helps, I'll get around soon to write something more detailed
on how to do this.
--
Matt Ronge
http://www.theronge.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden