Closed marco-skizza closed 5 months ago
Hello.
I tried your code, at least on Android. The problem is that in your example MyCameraView.Handler?.DisconnectHandler();
never gets called. When I added in ScannerLeakPage.xaml
:
...Title="ScannerLeakPage"
Unloaded="ContentPage_Unloaded">
and in ScannerLeakPage.xaml.cs
:
private void ContentPage_Unloaded(object sender, EventArgs e)
{
MyCameraView.Handler?.DisconnectHandler();
}
then DisconnectHandler()
and ~ScannerLeakPage()
both get called and memory footprint stays consistent.
I don't know why, at least on Android emulator, it takes 2-3 page openings and closings so that ~ScannerLeakPage()
gets called but after that it is called consistently.
Sorry for that! I forgot that I have the specific dispose code for iOS in place.
So I guess it's an iOS
issue only...
P.S.: Yeah, the Garbage Collector is not very predictable. For me it also takes several forth and back to observe it correctly.
Can you please report back the last version that you can confirm that got garage collected normally on iOS
I'm now using version 1.3.1
from NuGet.
This seems to be the last version where the control gets Garbage Collected.
Hopefully it is fixed in 1.4.2
. I have tested your example on Android and macOS and ~ScannerLeakPage()
gets triggered.
Please, if you can test on iOS and report back.
Yes, it works now. Many thanks!
Fixed in version 1.4.2
Hi afriscic
Many thanks for your work on this project lately.
Unfortunately, since version
1.4.0
theCameraView
started to leak again. I.e. the page containing aCameraView
never gets garbage collected anymore.I have a sample project that demonstrates that problem: https://github.com/marco-skizza/BarcodeScanningNativeMauiLeak
Steps to Reproduce:
~ScannerLeakPage() called
never gets loggedThis seems to be a problem with
iOS
as well asAndroid
.