The Windows.UI.Xaml.Controls.TextBox is never garbage collected on iOS. Similar to #3914, but no binding is required to produce this leak, simply place a TextBox control in a Page, then navigate away.
The Memory Instances counter shows the TextBox control is not being collected. One instance persists for each navigation:

Below are some images of the Xamarin Profiler's output showing the control persisting forever.


When inspecting the last snapshot, you can see that 30 Windows.UI.Xaml.Controls.TextBox are Persisted, meaning that they are not being released, which results in a memory leak.
On navigating back from a page, instances of the TextBox control in the previous page should be released, resulting in no memory leak.
Minimal reproducible example: https://github.com/TheRusstler/UnoMemoryLeakExample
Run these steps while using the Xamarin Profiler to watch the memory footprint increase linearly as you continue to navigate between the pages.
Windows.UI.Xaml.Controls.TextBox, one persisting for each navigation.We have been unable to find one so far.
Nuget Package:
Nuget Package Version(s): Uno.UI 3.0.17, Uno.UI 3.1.0-dev.485
Affected platform(s):
IDE:
Relevant plugins:
Thanks for the report!
I'm not able to repro this issue with the template pooling disabled. Can you try on your end by either waiting about a minute to take a snapshot ? You can also try disabling the template pool altogether.
Thanks for looking into this & all your incredible work with Uno.
I disabled template pooling, and ran the same test. There are 30 TextBox controls left over as before.
Were you able to repro using the example: https://github.com/TheRusstler/UnoMemoryLeakExample ?
Let me know if I can provide any more assistance - I will try to find a fix myself, but it looks like a tough first issue!




GitHub
A minimal example of iOS memory leak in Uno. Contribute to TheRusstler/UnoMemoryLeakExample development by creating an account on GitHub.
Thanks for the troubleshooting. One important part of the memory profiling is finding the roots. In general, when looking at the leaking objects, it's possible to find out the path of what causing the leak, for a specific instance. Could you paste a sceenshot of that as well ?
The source of the issue is caused by the "Delete Button" inside of a TextBox:

It contains a command that creates a hard between the TextBox and the Button instances, which I'll be fixing.