PROBLEM: Analyzing an iOS app with xcode instruments it appears to be a small but crucial (the snippet is indirectly executed all through the project) memory leak.
DESRCIPTION: We don't make any use of Entities references and follow the typical apple suggested core data object context stack
Here is a screenshot of instruments showing an apparent leak due to NSAsynchronousFetchRequest
maintaining a mutual indirect reference to a NSFetchResult
Here is the code snippet triggering the leak (removeing all the non-neccessary code, even the [weak self] still doesn't change it) according to Instruments
let anEntityFetch = NSFetchRequest<NSFetchRequestResult>(entityName: AnEntity.entityName)
let asyncFetchRequest = NSAsynchronousFetchRequest(fetchRequest: rangeQuantityFetch) { (asynchronousFetchResult) -> Void in
//
}
do {
// commenting out the execute there is no leak anymore
_ = try managedObjectContext.execute(asyncFetchRequest)
} catch {
}
The same thing happens enabling compile optimization flags.
QUESTION: Is there a possibility that it is only an Instruments or xcode bug? Or that it is a known core data issue? Or any useful hint to address me to the problem source would be really appreciated.