From 19d8869f1dc64d64a8b295985514716be5012a2c Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Wed, 16 Feb 2022 23:28:05 +0100 Subject: [PATCH] fix(ios): UIImage memory leaking after Image is disposed (#9777) --- packages/core/ui/image/index.ios.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/core/ui/image/index.ios.ts b/packages/core/ui/image/index.ios.ts index d99a00578..e3cd77e99 100644 --- a/packages/core/ui/image/index.ios.ts +++ b/packages/core/ui/image/index.ios.ts @@ -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);