wpf 进程“系统”引起的高 CPU 使用率

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16416927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:44:33  来源:igfitidea点击:

High CPU usage caused by process "System"

c#wpfprocess

提问by wzpchina

I'm programming a WPF application. I used BitmapCachein some windows, like this:

我正在编写 WPF 应用程序。我BitmapCache在一些窗口中使用过,像这样:

CacheMode = new BitmapCache() {
            EnableClearType = false,
            RenderAtScale = 2,
            SnapsToDevicePixels = false; }

Then:

然后:

  1. Run my appliction, cpu usage is normal.
  2. Ctrl+Alt+Del, show Task Manager, the process named "System" shows high CPU usage.
  1. 运行我的应用程序,cpu 使用率正常。
  2. Ctrl+ Alt+ Del,显示出任务管理器,命名为“系统”显示的CPU使用率过高的进程。

Process Explorer shows the problem that it is caused by these 2 threads:

Process Explorer显示它是由这2个线程引起的问题:

ntoskrnl.exe!WheaAttemptPhysicalPageOffline+0x350
dxgmms1.sys!VidMmInterface+0x26500

ntoskrnl.exe!WheaAttemptPhysicalPageOffline+0x350
dxgmms1.sys!VidMmInterface+0x26500

I used Intel HD Graphics.

我使用了英特尔高清显卡。

Is this a bug of WPF, direct or graphic driver? Does anybody know?

这是WPF,直接或图形驱动程序的错误吗?有人知道吗?

采纳答案by Hans Passant

The "System" process is a fake process that shows statistics for the Windows code that runs in ring 0. Device drivers live there, for example. Dxgmms1.sys is the memory manager for DirectX. WPF uses DirectX to render graphics. Bitmaps can use a lot of memory.

“系统”进程是一个虚假进程,它显示在环 0 中运行的 Windows 代码的统计信息。例如,设备驱动程序就在那里。Dxgmms1.sys 是 DirectX 的内存管理器。WPF 使用 DirectX 来渲染图形。位图可以使用大量内存。

Seeing a WPF app that uses bitmaps spending a lot of cpu time in a DirectX related device driver is therefore no great mystery. Intel HD Graphics is a bottom-of-the-barrel cheap implementation of a graphics accelerator. Spending fifty bucks on an AMD or NVidea video card would be a likely quick fix. Not asking WPF to scale the bitmap or limiting the rate at which it needs to be rendered because the visual tree was invalidated could well be another quick fix.

因此,看到使用位图的 WPF 应用程序在 DirectX 相关设备驱动程序中花费大量 CPU 时间并不神秘。英特尔高清显卡是图形加速器的最低价廉价实现。在 AMD 或 NVidea 显卡上花 50 美元可能是一个快速解决方案。不要求 WPF 缩放位图或限制它需要呈现的速率,因为可视化树无效很可能是另一个快速解决方案。