memory management issue?
memory management issue?
- Subject: memory management issue?
- From: Steven Crosley <email@hidden>
- Date: Fri, 1 Feb 2008 11:13:51 -0600
Hi,
I'm still pretty new to Cocoa and have just learned the hard way about
memory management. My app keeps dying in the function below. I've
gone back and cleaned up my classes according to the Memory Management
Rules (http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html#/
/apple_ref/doc/uid/20000994), but it doesn't seem to help. The first
and second time that this function gets accessed it works, no
problem. The third time it gets called it dies at:
array = [moc executeFetchRequest:request error:&error];
I put a breakpoint in right before it, and all the variables appear to
be in line. I've been stuck on it for a couple weeks now, so if anyone
has any suggestion of how I can better debug it, I'd really appreciate
it.
The error message that I get is: Program received signal:
“EXC_BAD_ACCESS”.
And here is the function:
- (void) getSelectedBuyer:(NSString*)uid
{
NSManagedObjectModel *mom = [self managedObjectModel];
NSManagedObjectContext *moc = [self managedObjectContext];
NSEntityDescription *buyerEntity = [[mom entitiesByName]
objectForKey:@"Buyer"];
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:buyerEntity];
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"active =
YES AND uid = %@", uid];
[request setPredicate:predicate];
NSError *error = nil;
NSArray *array;
array = [moc executeFetchRequest:request error:&error];
if ((error != nil) || (array == nil)) {
NSLog(@"Error while fetching\n%@",
([error localizedDescription] != nil) ? [error
localizedDescription] : @"Unknown Error");
exit(1);
}
NSEnumerator *buyerEnumerator = [array objectEnumerator];
[buyer release];
buyer = [buyerEnumerator nextObject];
[buyer setAddressBook];
}
Thanks,
Steven
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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