How to avoid massive memory leaks on WPF on .Net 3.5?

雨燕双飞 提交于 2020-01-13 10:23:21

问题


When I run my app targeted to .Net 3.5 it has massive memory leaks. 50mb every time I assign a UserControl to a local ref. I only ever create one instance of each UserControl. If I compile and run the same code targeted to .Net 4.0 everything runs fine hovering around the 50mb mark.

Is this a known isue with 3.5? I.e. it's not usable in prod?

/My clients only have 3.5 and won't be moving to 4.0 for awhile so i don't have the easy option


回答1:


Memory Leak Hotfixes for WPF 3.5 SP1
http://www.infoq.com/news/2010/06/WPF-Memory-Leaks

In particular, have a look at these two hotfixes, which have been fixed in .NET 4.0, but are available as hotfixes to users of .NET 3.5:

http://support.microsoft.com/kb/967634

http://support.microsoft.com/kb/967328




回答2:


What makes you think it is a leak, and not just memory that hasn't been garbage collected yet? Is there some impact outside of a number in a profiler that you are concerned with? If not, why worry. Would you rather your program used available memory or would you rather it used CPU cycles recovering unused objects?



来源:https://stackoverflow.com/questions/4071704/how-to-avoid-massive-memory-leaks-on-wpf-on-net-3-5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!