Mac 启动后突然很卡顿,每操作一次 app 都会等待响应问题
Macbook 昨晚习惯性合上睡眠,今天早上打开的时候好像还很顺畅,但打开一些 app 操作就变得非常卡顿。甚至 app 关闭都要等待一会儿。
本来是直接重启就可以好了的(万能方法),然后就想看看到底是什么进程在吃内存或者 CPU,导致操作卡顿。也怀疑有可能是中了病毒一直在挖矿之类的。结果打开活动监视器,内存压根没满,CPU 显示一直闲置 95% 以上。这排除了挖矿病毒的可能行。
然后尝试做一些操作观察是哪个进程 CPU 突然性的过高。发现了 WindowServer 进程,只要我挪动 app 面板,或者打开、关闭CPU 都会有一个飙升,并且看到 CPU 负载显示 突发性的阻塞了,系统和用户所占内存突然冒出一个长尖图形。
尝试关闭进程,提示推出此进程,则将推出登录。选择强制退出,然后重新登录到 Mac 系统。所有 app 都被杀死了,这跟重启好像也差不了多少,可能就是不需要重启一些底层的服务。此时再次观察 WindowServer 进程,界面性的操作依然会上升,但不存在卡顿的情况。
网上搜索了一下 WindowServer 这个进程的主要功能,找到一篇有关文章:How to reduce WindowServer CPU usage on your Mac,以下是摘录内容:
What is WindowServer on Mac?
Simply, it’s the macOS process that draws elements on the screen, whether they are application windows, icons, or websites. The more windows you have open at any one time, the more CPU cycles WindowServer needs. Most graphical elements are refreshed regularly, which is why WindowServer needs those CPU cycles. Every time you move a window around, edit an image in Photoshop, or switch to a different tab in Safari, WindowServer needs to redraw your screen.
When you consider that windows in macOS have lots of effects, such as transparency and drop shadows, it’s hardly surprising that drawing and redrawing them on screen consumes resources. However, on most Macs, the number of CPU cycles WindowServer consumes should be so small you don’t notice it.
Why does it use so many CPU cycles?
There are a few things that can cause WindowServer to use so many CPU cycles that you notice it or that it slows down your Mac. These include:
Misbehaving apps | Some applications “hogging” memory |
---|---|
Multiple displays | Having multiple displays can use up computer memory |
Cluttered desktop | Each icon has to be redrawn every time the screen contents change |
Visual effects | Older Macs struggle with modern graphics |
How to reduce WindowServer CPU usage
1. Close windows you don’t need
2. Turn off visual effects
3. Reduce the number of desktops in Mission Control
4. Check if apps and macOS are up to date
5. Restart your Mac
最后的 5 条方法都是比较有效果的,尤其是重启 Mac。看来处理 Mac 卡顿最佳的方法,还是重启 Mac。
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。