追踪 WPF 中的内存泄漏

发布于 2024-07-19 02:54:52 字数 546 浏览 3 评论 0原文

语境: 我们正在构建一个用于快速交付 WPF 应用程序的框架。 该框架使用 Autofac 作为 IoC 容器,还使用 ​​Prism v1 中的区域。 我们正在使用 Microsoft 的并行扩展来安排任务。

我们面临以下问题: 当我们使用空视图(因此只是一个带有区域和占位符控件的 shell)启动应用程序时,内存将保持稳定大约 60 秒,之后它将每秒增加 4kb,然后是 4kb,之后是 8kb。 因此,每 3 秒就会增加 16Kb 的内存压力。

我们做了什么努力来追踪泄漏。 我一开始使用 dotTrace,但我看不出间隔 30 分钟拍摄的 2 个快照之间有任何差异。 继续使用 .NET 内存分析器,因为它为我提供了更多信息,但我们再次看不到 2 个快照之间的任何差异。 我们可以看到创建了许多对象,但它们也被删除,导致增量为 0。 所以我转向了windbg,但结果是一样的。

另一个奇怪的事情是,当我们启动 sysinternals dbgvw 时,我们看不到应用程序中进行的任何调用。

您对我们下一步可以尝试找出罪魁祸首有什么建议吗?

Context:
We are building a framework for rapid delivery of WPF applications. This framework uses Autofac as an IoC container and also uses regions from Prism v1. We are scheduling tasks with Parallel extensions from Microsoft.

We are facing the following problem:
When we boot the application with empty views (so just a shell with regions and placeholder controls), the memory will remain stable for about 60 seconds and after that it will increase about every second with 4kb, then 4kb, after that 8kb. So every 3 seconds we have 16Kb added to our memory pressure.

What have we tried to track down the leak.
I started out by using dotTrace but I couldn't see any difference between 2 snapshots taken 30 minutes apart.
Moved on to .NET memory profiler because it gives me more information but again we cannot see any differences between 2 snapshots.
We can see that a number of objects get created but they are removed too and results in a delta of 0.
So I moved on to windbg but the result is the same.

Another weird thing is that when we start sysinternals dbgvw we don't see any calls being made in our applications.

Do you have any suggestions of what we might try next to find out what/who is the culprit?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云淡月浅 2024-07-26 02:54:52

如果您正在寻找非托管泄漏并正在使用 Visual Studio,您可以使用内置的 crt 函数获得令人惊讶的有用信息:

请参阅 相关问题的答案

If you are looking for unmanaged leaks and are using visual studio you can get surprisingly helpful information using the built in crt functions:

see an answer to a related question

黯然 2024-07-26 02:54:52

事实证明这是 WPF 内部的一个错误,解决方法是创建一个窗口处理程序作为第一个对象或其他东西。
多谢你们

As it turns out it was a bug inside WPF and the workaround was to create a window handler as very first object or something.
Thanks guys

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文