UWP compiled binding x:Bind produces memory leaks

前端 未结 2 1688
后悔当初
后悔当初 2021-02-02 11:25

While developing UWP application I recently found quite a few memory leaks preventing my pages from being collected by GC. I have a ContentPresenter on my page like:

<         


        
2条回答
  •  清酒与你
    2021-02-02 11:46

    Yes it does cause memory leak, to prevent that you can use following steps:

    1. Use IoC like UnityContainer and make your ViewModel or View ContainerControlLifeTime
    2. Assign null to ViewModel property at xaml.cs once you move out of UI.

提交回复
热议问题