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
[BUG] MemoryLeak on WPF #3091
Comments
Thanks for the detailed information, we will take a look at this. Was there a version that did work with no leaks? |
@ChrisPulman I dont know. I dont have live project of anything with ReactiveUI. I figured it out just after the first app was running in production for few days. |
Just a heads up. It is nothing to do with the Virtualizing itemscontrol template, the same is happening with just:
|
I ran a quick test from V10 through to the latest V17 and the same issue persists. I will look deeper into this to see if I can locate the source of the memory increase. |
This seems related to Dependency Properties leaking: From my modified version of the repro that:
Removing the DataTemplate for the ItemsControl fixes the leak which also lends weight to this theory |
Just a small question, if you find a fix, is it possible to get it to .net5 version? Since I am unable to upgrade
It didn't fix it for me |
@tomasfil I have a feeling you may have removed the template wrong. By Binding to ItemsControl, you get a default template that instantiates ViewModelViewHost. To "remove" the template, you need to replace it with something dumb like: <ItemsControl.ItemTemplate>
<DataTemplate><TextBlock Text="foo" /></DataTemplate>
</ItemsControl.ItemTemplate> |
Ah yes, you mean ItemTemplate. But like this it won't auto resolve Views right? (I am not at PC now) |
@tomasfil Correct - but we want to narrow the scope of what could be leaking, is the ViewModel holding onto something, or are we leaking Views (which will always leak ViewModels, since the View will always pin its own ViewModel) Once we take the View out of the equation, it goes away, so we know that the thing we're leaking is TestViews |
Can I do anything to help? |
Is this related to #1314 ? I may also meet the same situation. The |
Seems like it of what I have read. It is app breaking for me since items in itemsource change a lot in my app, so the memory leak is huge. That's kinda oof that the bug is there that long. |
To test if ReactiveUI was the actual issue in the sample I removed ReactiveUI and just left DynamicData.
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Describe the bug
Ok, I did have some investigation on Slack the other day with Annie.
There is something keeping ViewModels and Views from ReactiveUI in memory causing MemoryLeak.
Solution provided in repository might seems drastic. In project where I discovered it the ViewModels and Views eat up much more memory, so fraction % of them leaked causes to grow application into hundreds MB in RAM.
I was unable to find the cause of this.
In screenshots I you can see snapshots from dotMemory running without Visual Studio completely. So it is not caused by visual studio debugger as I thought.
I did test it on NET 5 -16.4.1
and NET 6 - 17.1.4
Both have the issue present (my main project is on 16.4.1, because I need to wait for Oracle Entity framework Core 6 to release, before I can upgrade.)
Steps To Reproduce
Run this project, and wait few seconds.
https://github.com/tomasfil/ReactiveUI_MemoryLeakTest_Wpf
Expected behaviour
No memory leak. Pun inteded
Screenshots
Environment
Additional context
The text was updated successfully, but these errors were encountered: