如何避免我的 C# .NET 应用程序生成大量软页面错误?

发布于 2024-12-18 05:52:06 字数 271 浏览 4 评论 0原文

我正在分析一个 C# .NET WinForms 应用程序,我注意到它会生成数百万个软页面错误,并且在工作过程中不断增加......

我知道在 .NET 中,页面错误的数量应用程序生成的数据通常很高,但数百万个页面错误似乎太多了...似乎应用程序触发了 GC 的竞争条件,有可能吗?

是否有一些已知的设计不当的代码可能会导致这种情况?如果代码中没有,.NET 框架是否有一些隐藏设置可以减少页面错误的数量?

越来越多的软页面错误的产生可以避免吗?

I'm profiling a C# .NET WinForms application and i have noticed that it generates millions of soft page faults and keep increasing during the work ...

I know that in .NET the number of pages fault that an application generates is usually high, but millions of page faults seems too much... Seems that the application triggered a race condition with the GC, is it possible ?

Are there some known ill designed piece of code that can lead to this situation ? If not in the code is there some hidden settings of the .NET framework that can reduce the number of page faults ?

The generation of an increasingly high number of soft page faults can be avoided ?

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

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

发布评论

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

评论(1

娇纵 2024-12-25 05:52:06

如果不是问题的话,我真的建议不要管它。如果您遇到性能问题 - 尝试并隔离产生最多页面错误的代码 - 它可能是您在使用大内存占用对象的地方。

尝试使您的“不安全”代码尽可能隔离和简单,即。将所有不安全代码封装在类或函数中。请记住,弄乱 .NET GC 可能会导致大多数不必要的复杂情况。

检查这篇文章是否有一些不安全的介绍(有点旧但仍然正确):
http://www.codeproject.com/KB/cs/unsafe_prog.aspx

另外,您可以延长 GC 收集的时间,这可能会有所帮助

I'd really recommends leaving this thing alone if it is not a problem. If you have performance problems though - Try and isolate the code that generates the most page faults - It is probably somewhere that you're using a large memory footprint object.

Try to keep your "unsafe" code as isolated and simple as possible, ie. encapsulate all the unsafe code in a class or function. Keep in mind that messing the .NET GC could lead to complications mostly unneeded.

Check this article for a bit of unsafe introduction (It's a bit old but still true):
http://www.codeproject.com/KB/cs/unsafe_prog.aspx

Also, you could raise the time until the GC collects, this might help

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