fix(ios): UIImage memory leaking after Image is disposed (#9777)

This commit is contained in:
Igor Randjelovic
2022-02-16 23:28:05 +01:00
committed by Nathan Walker
parent 47d45463a8
commit 19d8869f1d

View File

@ -24,6 +24,21 @@ export class Image extends ImageBase {
this._setNativeClipToBounds();
}
public disposeNativeView(): void {
super.disposeNativeView();
if (this.imageSource?.ios) {
// release the native UIImage
CFRelease(this.imageSource.ios);
}
this.imageSource = null;
if (this.nativeViewProtected?.image) {
this.nativeViewProtected.image = null;
}
}
private setTintColor(value: Color) {
if (value && this.nativeViewProtected.image && !this._templateImageWasCreated) {
this.nativeViewProtected.image = this.nativeViewProtected.image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);