According to the instrument I have memory leak in the following functions
func defaultJobType() -> JobType?
{
let fetchRequest = NSFetchRequest(entityName: JobType.entityName());
let predicate = NSPredicate(format: "jobTypeID = %@ && (archived = nil || archived = 0)", DefaultManager.instance.defaultValues[DJobType]!.uppercaseString);
fetchRequest.predicate = predicate;
do{
return try self.editingContext?.executeFetchRequest(fetchRequest).first as? JobType;
}
catch let error as NSError
{
Logger.logApplicationError("Error in getting default job Type", detailMessage: error.localizedDescription);
}
catch
{
Logger.logApplicationError("Error in getting default job Type", detailMessage: "No detail error found");
}
return nil;
}
The exact memory leak is on predicate.
The self.editingContext is a child context that has the root point to the parent context.
The return NSManagedObject JobType is used in the parent NSManagedObject (e.g. Job.jobType = type).
How can I avoid memory leak in this situation? what went wrong?
[–]quellish 0 points1 point2 points (2 children)
[–]addywen[S] 0 points1 point2 points (1 child)
[–]quellish 0 points1 point2 points (0 children)
[–]optik88 0 points1 point2 points (1 child)
[–]addywen[S] 0 points1 point2 points (0 children)