加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – Silverlight:如何从内存中卸载(处置)图像?

发布时间:2020-12-15 08:30:07 所属栏目:百科 来源:网络整理
导读:我有一个图像控件,显示一个大的jpg文件,占用大约50mb的内存. 如果不再需要此控件,该如何处理?我尝试将其从父容器中删除,将其设置为null并将其Source属性转换为null,但内存使用率仍保持不变… 任何建议将受到高度赞赏! 解决方法 我终于找到了问题的答案. 问
我有一个图像控件,显示一个大的jpg文件,占用大约50mb的内存.
如果不再需要此控件,该如何处理?我尝试将其从父容器中删除,将其设置为null并将其Source属性转换为null,但内存使用率仍保持不变…
任何建议将受到高度赞赏!

解决方法

我终于找到了问题的答案.
问题出在Silverlight中的内存泄漏错误中.
我在这里找到了解决这个问题的方法:
http://blogs.msdn.com/silverlight_sdk/pages/silverlight-bugs-and-workarounds.aspx

Memory Leak when you Dynamically add
and remove Images

Workaround: When dynamically adding or
removing BitmapImages from an
application (a.k.a. adding/removing
from the tree),you should set
Image.Source = null before removing
the Image element from the tree. This
will make the BitmapImage eligible for
garbage collection. Bug Status: Active
bug. *

谢谢大家的建议!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读