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

前端之家收集整理的这篇文章主要介绍了c# – Silverlight:如何从内存中卸载(处置)图像?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个图像控件,显示一个大的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. *

谢谢大家的建议!

原文链接:https://www.f2er.com/csharp/243805.html

猜你在找的C#相关文章