Xamarin.Forms UWP 内存泄漏

Memory leaks in Xamarin.Forms UWP

我在 UWP 上有 Xamarin.Forms 应用程序 运行,它有一个包含第三方组件的页面。我导航到该页面并导航离开,处理该页面及其中的所有组件。

我调用 GC.Collect() 并希望页面及其控件不再在内存中。但我发现该页面仍在内存中,内存泄漏的底部是带有 Depenent Handle(或我假设的事件处理程序)的第三方组件:

在向第三方报告此事后,他们做出以下回应:

I have discussed this with the dev team and according to them releasing the controls from the visual tree is performed by the platform and it is not performed immediately after removing it, so calling the garbage collector and checking if it is still in memory doesn't mean it is leaking. the platform could release it at another time.

现在我认为上述说法是不正确的...但我无法在 Internet 或 MS 文档中找到任何反驳它的内容。

据我所知,如果我处理一个页面及其所有内容并调用垃圾收集器,该页面及其所有控件应该从内存中消失

这是正确的吗?

所以我认为我的说法是正确的:

If you navigate to and from a page and dispose of the page and all its components and call GC.Collect(). Then the page and all its components should be gone from memory.

我发现这篇文章正是这样做的: https://www.xamarinhelp.com/tracking-memory-leaks-xamarin-profiler/

"You will want to press the snapshot button once your app has loaded, to get a baseline. Then, lets navigate to the second page, and press back again. I would create another snapshot now. Then I might keep on doing the navigation a few more times and pressing snapshot again."

"In our example, we went back and forth between the MainPage and SecondPage. We should only see one new SecondPage at most between snapshots, but here we see that multiple were created and are still active."