Simple WPF sample causes uncontrolled memory growth

后端 未结 4 773
天命终不由人
天命终不由人 2021-02-02 16:49

I have boiled down an issue I\'m seeing in one of my applications to an incredibly simple reproduction sample. I need to know if there\'s something amiss or something I\'m missi

4条回答
  •  故里飘歌
    2021-02-02 17:26

    WPF in .NET 3 and 3.5 has an internal memory leak. It only triggers under certain situations. We could never figure out exactly what triggers it, but we had it in our app. Apparently it's fixed in .NET 4.

    I think it's the same as the one mentioned in this blog post

    At any rate, putting the following code in the App.xaml.cs constructor solved it for us

    public partial class App : Application
    {
       public App() 
       { 
           new HwndSource(new HwndSourceParameters()); 
       } 
    }
    

    If nothing else solves it, try that and see

提交回复
热议问题