MLUpdateTask leaking completionHandler

Originator:Mike.house.nsk
Number:rdar://FB7641639 Date Originated:03/27/2020
Status:Open Resolved:
Product:CoreML API Product Version:iOS 13+
Classification:Incorrect/Unexpected Behavior Reproducible:Always
 
After MLUpdateTask ended its work a completionHandler is not released.

Steps to reproduce:
- create MLUpdateTask and pass there a completion handler block
- waiting until MLUpdateTask ends its work and calls completion handler. 
- remove/release reference to the MLUpdateTask object to be released by ARC
- Observe that objects you passed to completion handler are released (deinit) and Debug Memory Graph doesn’t have them also

Expected: objects passed to the completion handler are released as MLUpdateTask ended its work and there no more references for these objects
Unexpected: MLUpdateTask ended its work, but objects passed to the completion handler still in the memory (Debug Memory Graph) and not released with ARC (deinit)

Debug Memory Graph shows that objects are hold by closure that is hold by MLUpdateProgressHandlers instance.

I’ve tried use MLUpdateProgressHandlers object instead of simple completion handler for MLUpdateTask initialisation, but I’ve seen the same behaviour.

Model used for training is just K Nearest Neighbors Classifier

The same problem was found in Apple sample project https://developer.apple.com/documentation/coreml/core_ml_api/personalizing_a_model_with_on-device_updates

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!