WPF 演示字体缓存。这是什么?

发布于 2024-08-31 11:58:05 字数 659 浏览 5 评论 0原文

我有 .Net 3.5 SP1,并在 WPF 中完成开发。

每当我运行 WPF 应用程序时,我都会看到一个名为“PresentationFontCache”的进程出现在我的进程列表(在任务管理器上)中。该进程虽然看起来无害,但实际上即使在 WPF 应用程序关闭后也驻留在内存中。这个过程实际上是怎样的?它有什么作用?

因此,当我尝试检查内存使用情况(通过多次执行和关闭应用程序)时,该进程给人一种感觉某些内存仍在使用中。我还观察到这个进程可能会严重消耗资源(在某些条件下会占用 30% 的 CPU 使用率和/或 100 MB 的内存!!!)。

我找到了名为“Windows Presentation Foundation Font Cache 3.0.0.0”的 Windows 服务,它可能负责生成此进程。该服务声称它通过缓存常用字体数据来优化 WPF 应用程序的性能。如果该服务尚未运行,WPF 应用程序将启动该服务。它可以被禁用,尽管这样做会降低WPF应用程序的性能。

但是为什么Windows服务本身在WPF应用程序关闭后不关闭进程呢?

或者该服务实际上会集体缓存所有 WPF 应用程序使用的字体信息,以便下次任何类似的应用程序重新运行时,将使用缓存而不重新生成应用程序的字体?如果是的话,那不是一种不能被垃圾收集的数据吗?这不是导致内存泄漏的可能原因吗?

请照亮我。

谢谢 维尼特。

I have .Net 3.5 SP1 with developement done in WPF.

Whenver I run my WPF application I see a process named "PresentationFontCache" appears in my Process List (on Task Manager). The process, though appears harmless, actually resides in the memory even after the WPF application is closed. What is this process actually? What does it do?

So when I try to check the memory usage (by executing and closing the application numerous times) the process gives a feel that some memory is still in use. also I have observed that this process can turn nastily resource hungry (30% CPU usage and/or 100 MB memory usage under certain conditions!!!).

I located the windows service, named "Windows Presentation Foundation Font Cache 3.0.0.0", which is probably responsible for generating this process. This service claims that it optimizes performance of WPF applications by caching commonly used font data. WPF applications will start this service if it is not already running. It can be disabled, though doing so will degrade the performance of WPF applications..

But then why doesnt the windows service itself close the process after the WPF application is closed.

Or is it that this services actually caches the font information used for any WPF apps collectively so that next time any of the similar apps, when rerun, will use the cache without regenrating the fonts for the application? If so isnt that a type of data which cannot be garbage collected? Isnt that a probable cause leading to memory leak?

Please elight me.

Thx
Vinit.

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

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

发布评论

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

评论(1

无敌元气妹 2024-09-07 11:58:06

该服务旨在提高 WPF 应用程序的性能并增加 WPF 程序(或同一程序的不同实例)之间的共享资源量。源代码作为 参考源代码中心,以及有关 WPF 应用程序性能的更多一般信息,请访问 此处

有一些孤立的实例表明此服务会导致问题,但就其正在执行的操作而言,我认为偶尔的 CPU 峰值和 100mb 内存使用不会产生问题。

如果您认为该服务占用了太多资源,您可以安全地禁用该服务,但最好分析/测量该服务对您的应用程序的影响。

This service is designed to improve the performance of WPF applications and increase the amount of shared resources between WPF programs (or different instances of the same program). The source is available for it as part of the Reference Source Code Center, and some more information on WPF application performance in general can be found here.

There are isolated instances of where this service causes a problem, but for what it's doing I don't think that occasional CPU spikes and 100mb memory usage are problematic.

You can safely disable the service if you believe it is taking up too many resources, but you're better off profiling / measuring what effect that has on your application.

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