UWP映像访问中的内存泄漏 [英] Memory leak in UWP image access

查看:82
本文介绍了UWP映像访问中的内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用一个按钮创建了一个空白应用程序(VS 2017).点击事件代码如下所示.  这会像疯狂一样泄漏内存,并在2000多次迭代后死亡.  有人知道这里有什么问题吗?

I created a blank app (VS 2017) with a single button.  The click event code looks like what follows.  This leaks memory like crazy and dies after 2000+ iterations.  Does anyone understand what is wrong here?


推荐答案

Paul723,

Hi Paul723,

我建议使用一个内存探查器,该探查器可以将 Task的实例追溯到GC根目录.某种东西正在引用它们,您需要找出那是什么.

I would suggest using a memory profiler that can trace the instances of Task back to a GC root.  Something is holding a reference to them and you need to find out what that is.

此外,请参考以下主题(请参见 斯蒂芬·克莱尔(Stephen Cleary)的回复.

In addition, please refer the following thread (see Stephen Cleary's reply).

>>会导致内存泄漏(如果您await正在执行I/O操作).最好是 总是完成您的Task s (这意味着总是让您的 async方法迟早会返回).

>>it will cause a memory leak (if you're awaiting an I/O operation). It's best to always complete your Tasks (and this means always having your async methods return sooner or later).

http://stackoverflow.com/questions/12953377 /在异步编程中晃动等待和可能的内存泄漏

最诚挚的问候,

吴可乐


这篇关于UWP映像访问中的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆