Help! NSFetchRequest/NSManagedObjectModel weirdness (or a memory problem)
Help! NSFetchRequest/NSManagedObjectModel weirdness (or a memory problem)
- Subject: Help! NSFetchRequest/NSManagedObjectModel weirdness (or a memory problem)
- From: "Doug Knowles" <email@hidden>
- Date: Sat, 6 Jan 2007 20:47:37 -0500
I've spent the last several days trying to track down a crash in my
Core Data app, and I'm stumped.
The app crashes in the handler for an idle-time notification; the
handler tries to execute a query against the store by executing a
fetch request template it gets from the document's single model. The
query fails because the fetch request the document obtains via:
[[self managedObjectModel]
fetchRequestTemplateForName:@"recordsNeedingCacheUpdate"];
...is corrupt: the NSEntityDescription referenced by the fetch request
has been deallocated.
I used "MallocScribble" to mark the deallocated objects, and a watch
point to find where it's happening, and it turns out that the entity
description is being deallocated, along with the NSManagedObjectModel
that contains it, by the autorelease pool released when the
application startup and creation of the untitled document is complete.
I can't find anyplace where I autorelease anything in the vicinity of
the few places I reference the document's model.
Another observation that has me confused is this: I use the document's
NSManagedObjectModel to retrieve the NSFetchRequest template; the
NSFetchRequest's entity (an NSEntityDescription) has a reference to
its NSManagedObjectModel, which is a different object than the model I
used to retrieve it in the first place; it is entity's model that has
been autoreleased. I can't figure out why the NSEntityDescription's
model would be different from the model I used to find it.
At this point, I can't figure out whether to pursue this as a memory
error (did I lose track of pointers and autorelease the model thinking
it was something else?) or an core data problem (is there something
about model management I'm missing?). Could my Core Data model be
corrupt? If so, is there a way to check the model or force it to be
more completely reconstructed?
Any ideas for isolating this would be appreciated.
Doug K;
_______________________________________________
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