Silverlight 内存泄漏
我们有一个相当大的 silverlight 4 应用程序。我们正在寻找应用程序中的内存泄漏,这已成为一项艰巨的任务。
对于那些看过原始帖子的人来说,事情已经完全改变了!
我意识到 ANTS 内存分析器没有向我展示正确的内容。这是因为内存泄漏不是在托管代码中,而是在本机代码中。我确实修复了 ANTS 的一些问题 - 它是解决托管代码内存泄漏的好工具。
所以我找到了这个博客,
这非常棒。我使用 xPerf 和 xPerfViewer 查看本机堆并查看我怀疑的实际内存泄漏。
所以我可以看到一个看起来像这样的堆栈跟踪,
CCoreServices::Draw
CCoreServices::Tick
CUElement::Render
CUIElement::Render
CUIElement::RenderWithTransform
CUIElement::RenderVisual
CUIElement::RenderChildren
{Repeat of the above in a recursive fashion}
所以在这个“Render”方法中的某个地方它分配了大约 520 字节的内存,据我所知它并没有释放它。
我还可以看到调用的方法或类
SDBitmapCreate
也在泄漏内存。
有趣的是,我似乎发现了一些东西,但我不太确定是什么。
还有其他建议吗?
谢谢。
We have a rather large silverlight 4 application. We are in the process of finding memory leaks in the application and this has turned into a daunting task.
Things have changed completely with this one, for those of you that have seen the original post!
I realised that ANTS memory profiler wasn't showing me the right stuff. That was because the memory leak was not in the managed code, but in the native code. I did fix some issues with ANTS - it is a good tool for managed code memory leaks.
So I found this blog,
Which was excellent. I used xPerf and xPerfViewer to view the native heap and see what I suspect is the actual memory leak.
So I can see a stack trace which looks like this,
CCoreServices::Draw
CCoreServices::Tick
CUElement::Render
CUIElement::Render
CUIElement::RenderWithTransform
CUIElement::RenderVisual
CUIElement::RenderChildren
{Repeat of the above in a recursive fashion}
So in this 'Render' method somewhere it allocates about 520 bytes of memory, and as far as I can tell it doesn't free it.
I can also see a method or class called
SDBitmapCreate
is leaking memory too.
Interesting because it seems like I have found something, but I am not really sure what.
Any other suggestions?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先,我不知道有什么针对 silverlight 的内存泄漏工具。
几周前我经历了我所认为的内存泄漏问题。结果我的 Silverlight 应用程序在画布上出现了流氓儿童。
我的问题可能不是你的问题,但它可能会引起你的思考。
在使用服务器的结果重新填充列表之前,我必须从适当的画布中删除所有子项。清除列表还不够。:
boxDataLabel 是标签类型的列表。
祝你好运。
First Off, I do not know of any memory leak tools for silverlight.
I experienced what I thought where memory leak problems a few weeks ago. Turns out my Silverlight application had rogue children in the canvas.
My issue may not be your issue, but it may get you thinking.
Before I re-populated my list with results from the server, I had to remove all children from appropriate canvas. Clearing the list wasn't enough.:
boxDataLabel is a list of type Label.
good luck.
Xaml 中的内联 DataTemplate 存在官方内存泄漏。您可以在这里阅读有关它的帖子: http://forums.silverlight.net/forums/ t/171739.aspx。
Microsoft 已发布了一个服务版本(更新版本为 4.0.50826.0),应该可以解决该问题:http://timheuer.com/blog/archive/2010/09/01/silverlight-service-release-september-2010-gdr1.aspx
记住如果服务版本修复了(部分)您的问题,请更新主机 html 文件中的最低版本。
There is an official memory leak regarding inline DataTemplates in Xaml. You can read a thread about it here: http://forums.silverlight.net/forums/t/171739.aspx.
Microsoft have released a service release (update build is 4.0.50826.0) that should fix the issue: http://timheuer.com/blog/archive/2010/09/01/silverlight-service-release-september-2010-gdr1.aspx
Remember to update the minimum version in the host html file if the service release fix (some of) your problems.
如果我处于您的情况,我会尝试创建一个简单的测试应用程序来演示泄漏,只是为了仔细检查它在实际代码之外是否可重复。这证明这不是代码中的微妙错误。然后,我会将测试应用程序发布到 MS Silverlight 论坛,该论坛由 MS 人员监控。如果您订阅了 MSDN,或者您的公司与 MS 签订了支持协议,我也会向 MS 开一张“票”(忘记他们实际的称呼)。
If I were in your situation I would try to create a simple test application that demos the leak, just to double-check it is repeatable outside of your actual code. This proves that it isn't a subtle bug in your code. Then, I would post the test app to the MS Silverlight forums, which is monitored by MS folks. If you have an MSDN subscription, or if your company has a support agreement with MS, I would also open up a "ticket" (forget what they actually call them) with MS as well.
这里有一个关于解决 Silverlight 内存泄漏问题的很好的教程:http://davybrion.com/blog/2009/08/finding-memory-leaks-in-silverlight-with-windbg/。它很复杂,并且您必须处理 WinDBG 命令,但我发现它在过去很有帮助。当然,这并不能具体回答您的问题,但它可能会为您指明正确的方向。
There's a good tutorial on troubleshooting Silverlight memory leaks here: http://davybrion.com/blog/2009/08/finding-memory-leaks-in-silverlight-with-windbg/. It's complicated, and you have to deal with WinDBG commands, but I've found it helpful in the past. Of course, this doesn't answer your question specifically, but it may point you in the right direction.