Re: Core Data SIGSEGV when opening an existing document
Re: Core Data SIGSEGV when opening an existing document
- Subject: Re: Core Data SIGSEGV when opening an existing document
- From: Larry Fransson <email@hidden>
- Date: Wed, 19 Apr 2006 20:27:33 -0700
On Apr 19, 2006, at 12:18 AM, mmalcolm crawford wrote:
Why not start with something simple like explicitly fetching all
instances of all entities at startup (see "Batch Faulting..."
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468-SW3>)?
So I looked at that again, and tried to implement something that
looks like it. It may or may not be working as advertised, because
I'm still getting the crash.
Where should I be doing the prefetching and batch faulting? -
windowControllerDidLoadNib: seems to be the only place I get any
results. Any place else (I tried three other methods that are called
before that, starting with -init), and the array count is 0. I've
tried it both before and after calling super's implementation.
Here is the code I'm using for prefetching and batch faulting:
//Prefetch all entries
NSManagedObjectContext *moc = [self managedObjectContext];
NSEntityDescription *entryED = [NSEntityDescription
entityForName:@"LogBookEntry" inManagedObjectContext:moc];
NSFetchRequest *entryFR = [[NSFetchRequest alloc] init] ;
[entryFR setEntity:entryED];
NSError *err = nil;
NSArray *entries = [moc executeFetchRequest:entryFR error:&err];
if(err) NSLog(@"Error fetching entries");
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF IN
%@", entries];
[entryFR setPredicate:predicate];
err = nil;
entries = [moc executeFetchRequest:entryFR error:&err];
if(err) NSLog(@"Error prefetching entries");
NSLog(@"fetched %i entries", [entries count]);
[entryFR release];
Does this look about right? I get an array of 2800+ objects
returned, which is good. I can't tell if the batch fault works or
not, because calling -isFault on the returned objects returns YES.
And in any case, I'm still getting the SIGSEGV, which doesn't happen
when I open the document with just 500 objects.
I've checked for leaks as best I know how. Malloc Debug says that
300-ish bytes are leaked (with 500 objects), and command line leaks
says 0. It doesn't seem like I should be using that much memory
anyway. There are 40-some attributes and a single to-one
relationship, but there are only about 120 related objects, and most
of the attributes are doubles with a couple of strings and a date.
Larry Fransson
Subcritical
_______________________________________________
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