• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Basic Coredata / threading question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic Coredata / threading question


  • Subject: Re: Basic Coredata / threading question
  • From: Jim Correia <email@hidden>
  • Date: Sat, 7 Apr 2007 13:39:29 -0400

On Apr 6, 2007, at 3:26 PM, Walt Horat wrote:

I have an application that keeps a large model. The app fires off a number of network queries in parallel - each of these is fired on a separate thread. Each of these threads needs to access the model when the response returns, and execute a fetch which will require coredata to touch nearly every object in the model.

It seems that if each thread is given its own managed object context, the app will have N copies of the model all in memory at the same time - this does not sound like a good strategy for large datasets.

Seems is a good way to spend a lot of time optimizing the wrong code. Use the performance tools to take meaningful measurements, and optimize the code that matters.


In particular, if CoreData did work this way (it doesn't), the relevant question is does the usage patterns in your application make this a problem? If not, then you can spend that time working on other problems.

Many of the recent CoreData threading questions are answered in the documentation and/or recent posts to this list (which are available in the mailing list archive. I'll refer once again to

	http://lists.apple.com/archives/cocoa-dev/2007/Mar/msg00739.html

which says:

Although each NSManagedObject instance is a distinct object between
NSManagedObjectContexts, the actual data from the database is shared
copy-on-write. So, for most apps, there is not a lot of memory to be saved
by sharing managed objects anyway.


If you keep managed objects and their contexts private to each thread, and
use -objectRegisteredForID:, -objectWithID:, or - executeFetchRequest: to
"copy" managed objects between threads, you'll find yourself living in a
much more maintainable and comprehensible threading model.


Jim
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >A question about formatters/validation (From: Shamyl Zakariya <email@hidden>)
 >Basic Coredata / threading question (From: Walt Horat <email@hidden>)

  • Prev by Date: Re: characterAtIndex: method and composite characters (SOLVED)
  • Next by Date: Updating views (threading?)
  • Previous by thread: Re: Basic Coredata / threading question
  • Next by thread: problem with interaction between NSTableView and fieldEditor
  • Index(es):
    • Date
    • Thread