When final testing my application in Instruments for leaks, I come across 2 odd leaks:
Leaked Object: _PFArray, #: 1 Address: 0x2a11c0 Size: 32 Bytes Responsible Library: CoreData Responsible Frame: newFetchedRowsForFetchPlan_MT
And
Leaked Object: Malloc 16 Bytes, #: 1 Address: 0x24d6b0 Size: 16 Bytes Responsible Library: CoreData Responsible Frame: newFetchedRowsForFetchPlan_MT
The stack traces for both leaks point to:
records = [[self.managedObjectContext executeFetchRequest:request error:&error] retain];
in a CoreData Fetch.
And
[self.window makeKeyAndVisible];
What are these leaks? I have never seen them before. They do not pop up when I build and Analyze. Does anybody have any suggestions?
Thanks!!
EDIT:
Here is the code around the records array. Records is just an NSarray declared in the .h.
/*
Fetch existing events.
Create a fetch request; find the Event entity and assign it to the request; add a sort descriptor; then execute the fetch.
*/
marblebeingdragged=YES;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Child" inManagedObjectContext:_managedObjectContext];
[request setEntity:entity];
// Order the events by creation date, most recent first.
NSSortDescriptor *nameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
NSSortDescriptor *prizeDescriptor = [[NSSortDescriptor alloc] initWithKey:@"prize" ascending:NO];
NSSortDescriptor *neededDescriptor = [[NSSortDescriptor alloc] initWithKey:@"marblesneeded" ascending:NO];
NSSortDescriptor *colorDescriptor = [[NSSortDescriptor alloc] initWithKey:@"color" ascending:NO];
NSSortDescriptor *reachedDiscriptor = [[NSSortDescriptor alloc] initWithKey:@"prizereached" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:nameDescriptor,prizeDescriptor,neededDescriptor,colorDescriptor, nil];
[request setSortDescriptors:sortDescriptors];
[nameDescriptor release];
[colorDescriptor release];
[prizeDescriptor release];
[neededDescriptor release];
[reachedDiscriptor release];
[sortDescriptors release];
// Execute the fetch -- create a copy of the result.
NSError *error = nil;
records = [[self.managedObjectContext executeFetchRequest:request error:&error] retain];
You need to release the “records” object. And you need to release it after you are done using it, NOT in dealloc method. Post more of your code. How did you define records? Post the entire core data code block please if you want any help.
Edit:
Either use this
OR this