-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak in RadioButton ControlTemplate #23199
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
Closed similar issues:
|
I can repro this issue at Windows platform on the latest 17.11.0 Preview 2.1(8.0.60). |
Somehow these pass, but the sample here has an issue: * dotnet#23199 Past links related to `RadioButton`: * dotnet#18365 * dotnet#21151
Somehow these pass, but the sample here has an issue: * dotnet#23199 Past links related to `RadioButton` leaks: * dotnet#18365 * dotnet#21151
Somehow these pass, but the sample here has an issue: * dotnet#23199 After further investigation, I'm not sure there is an actual issue. Past links related to `RadioButton` leaks: * dotnet#18365 * dotnet#21151
After deeper investigation, I don't think I'm seeing a problem here on Windows. First, I would recommend these changes in the sample to test this: The sample was calling With this change, I see memory being pretty stable and going up and down, even if I click "Recreate List" very quickly: I don't see extra To be sure there wasn't a problem, I wrote a couple new tests in .NET MAUI, but they pass successfully: Let me know if I missed something, or if I should try a different platform. Thanks! |
This expands the tests to cover more controls and areas. * Add test cases for more controls: * `Ellipse` * `Grid` * `Path` * `Line` * `Path` * `RadioButton` * `Rectangle` * `RoundRectangle` * Expand tests for a couple controls: * `Border` has a `StrokeShape` * Any `TemplatedView` gets a `ControlTemplate` * Re-enable `ListView` for Android This should work now after merging: * dotnet/android#8900 * dotnet#23120 * Add a complicated test case for `BindableLayout` Similar to the case at: * dotnet#23199
Hi, thank you very much for taking a look! I will retest that in our environment to see if anything changes. We replace the whole collection and just use an array instead of ObservableCollection in our app. However, we also use a lot of rx with DynamicData where we filter and sort lists and bind them using ReadOnlyObservableCollections. They use Reset when swapping larger collections. Would you generally recommend to change that to replace the collections instead? |
The main thing to check is that an event fires once, instead of In my example, it was actually |
* [tests] test a lot more things in `MemoryTests.cs` This expands the tests to cover more controls and areas. * Add test cases for more controls: * `Ellipse` * `Grid` * `Path` * `Line` * `Path` * `RadioButton` * `Rectangle` * `RoundRectangle` * Expand tests for a couple controls: * `Border` has a `StrokeShape` * Any `TemplatedView` gets a `ControlTemplate` * Re-enable `ListView` for Android This should work now after merging: * dotnet/android#8900 * #23120 * Add a complicated test case for `BindableLayout` Similar to the case at: * #23199 * Skip `ListView` on API 23
* Simplify Development.md (#23142) * Simplify Development.md * Update .github/DEVELOPMENT.md Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com> * Update .github/DEVELOPMENT.md Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com> * Update .github/DEVELOPMENT.md Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com> * Update .github/DEVELOPMENT.md Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com> * Update DEVELOPMENT.md * - modify and move advanced tips to different file * Update DEVELOPMENT.md * Update .github/DEVELOPMENT.md Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> * Update docs/DevelopmentTips.md Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> * Update docs/DevelopmentTips.md Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> * - updates based on review --------- Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com> Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> * Wire RefreshView up to our xplat layout workflow (#23169) (#23218) * Use better layout/measure path with refreshview * - fix naming * - set RefreshView content to maui compatible container * - add test * - fix null operator * Update Issue23029.xaml.cs * - fix content panel so it removes previous content * - add additional check * Remove adding to FutureAccessList as the app is running with runFullTrust capability (#23047) * Call base.OnResume if Existing NavigationFragment Early (#23187) * VSCode no longer uses MAUI to launch (#23222) * [Android] Fix flyout behaviour switching exception (#22453) * Fix flyout behaviour switching exception * Tests added * Flyout test page added * Flyoutpage test fixes * Flyout toggle test added * Remove duplicate ] characters * Flyout test pages added * Check for platforms * Fix title * - fix tests --------- Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> Co-authored-by: Shane Neuville <shneuvil@microsoft.com> * Renamed the project because macOS uses .app (#23223) * Renamed the project because macOS uses .app * And the folder * merge first * ns * Move tests to new location (#23251) * Split SingleProject targets (#23269) * Split SingleProject targets * Update Microsoft.Maui.Controls.SingleProject.Before.targets * Update bug-report.yml with 8.0.61 (#23273) * Null terminate Page on TabbedRenderer (#23290) Co-authored-by: Shane Neuville <shneuvil@microsoft.com> * [Windows] Improve performance in accessibility extensions (#22698) * AccessibilityExtensions: Add missing braces * AccessibilityExtensions: Enable nullability and improve performance * Update shipped & unshipped API --------- Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com> * [Android] Avoid double event subscribes in gesture manager (#23242) * [Android] Avoid double event subscribes in gesture manager * Fix typo in test text * Bump Microsoft.Web.WebView2 from 1.0.2151.40 to 1.0.2592.51 (#23209) * [tests] test a lot more things in `MemoryTests.cs` (#23324) * [tests] test a lot more things in `MemoryTests.cs` This expands the tests to cover more controls and areas. * Add test cases for more controls: * `Ellipse` * `Grid` * `Path` * `Line` * `Path` * `RadioButton` * `Rectangle` * `RoundRectangle` * Expand tests for a couple controls: * `Border` has a `StrokeShape` * Any `TemplatedView` gets a `ControlTemplate` * Re-enable `ListView` for Android This should work now after merging: * dotnet/android#8900 * #23120 * Add a complicated test case for `BindableLayout` Similar to the case at: * #23199 * Skip `ListView` on API 23 * Bump Appium version to 2.11 (#23337) * Bump Appium version to 2.11 * Update CarouselViewUITests.UpdateCurrentItem.cs * Update appium-install.ps1 * Update CarouselViewUITests.UpdateCurrentItem.cs * Simplify `NavigationRootManager.Connect` on the Windows platform. (#23345) * Simplify `NavigationRootManager.Connect` on the Windows platform. * Use ternary operator syntax * Removed extra tabs * Moved `_disconnected = false;` to `if (_disconnected)` * Bump Appium Drivers (#23349) * Fix Merge --------- Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com> Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com> Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Thomas Muller <imuller@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com> Co-authored-by: Jonathan Dick <jodick@microsoft.com> Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com> Co-authored-by: Takym (たかやま) <15681312+Takym@users.noreply.github.com>
If you are always seeing 80, it's probably not a leak. It just means that it takes a few GCs for them to go away. A leak would mean 80->100->120 that continuously grows. In my screenshot above, if I let the app "rest" for a second, that is what caused this drop to appear: If you are testing and see something different than me, see if you can find out which object type is growing. I can take another look in that case, thanks! |
Yes, I see that the ellipse is not leaking like I suggested initially, I have the same results after adding the additional GC calls. I was wondering why the heap size is still increasing between the snapshots (+200kb in my snapshot), should it not go back to 0 increase or even decrease when calling GC manually? |
For me, it was going down (lower than a previous collection) as I waited longer & clicked longer. There was a stable point the memory usage would hover around. If you see it going up, diff a few snapshots to see if you can figure out what object (full namespace + type) is the cause. |
@jonathanpeppers thank you, I will close the issue for now and raise a new one if necessary. |
Description
Hi,
we found that when refreshing a list which contains customized RadioButtons, hundreds of Ellipse objects from the template remain in memory.
I created a sample repo which just uses the control template from the maui documentation https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/radiobutton?view=net-maui-8.0#redefine-radiobutton-appearance
When refreshing the list a few times, doing GC.Collects in between and taking a snapshot just using Visual Studio, I found the same issue occuring in the sample repo:
Same behavior happens with a Release build + JetBrains dotMemory in our production app.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/krdmllr/MauiMemoryLeaks
Version with bug
8.0.60 SR6
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
windows 10.0.19041.0
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: