MacOS – How to isolate macOS 10.14.6 Mojave freezing 1-2 seconds every few minutes except for sound and the mouse

hangmacosmojaveperformance

Since a week or two I am experiencing a very strange problem on my MacBook Pro running macOS 10.14.6 Mojave. (Build 18G103)

No matter what I'm doing, typing something in a browser or text editor or other application, watching a video on youtube or in VLC, every few minutes the whole system become non-responsive for like 1 or 2 seconds.

When the machine is "stunned":

  • The keyboard does not respond to typing in any app

  • video playback stops no matter which app or browser

  • mouse clicks don't register

  • cursor movement does work and respond

  • any sound that is playing, keeps on playing normally.

    When I was typing something, the letters don't appear, but after 1-2 sec when the system continues, the letters still appear as if they were cached somehow.

This persists across reboots, activity monitor shows no fancy stuff taking CPU in the background. I did not recently install any particular new software myself, other than just updates. It makes no difference if I have multiple apps running or only the one I'm using.

Is there any way to find out what application or process is causing these short freezes, and preferably get rid of them?

Best Answer

I've seen precisely this problem on many, many versions of macOS, both release and beta. Usually the delay is caused by some Apple process. For me, diagnosing is not the problem, the problem is fixing it.

You didn't say how much memory your computer has. A few years ago, Apple introduced compression on virtual memory. This is especially important in SSD-based computers: it decreases wear on the SSD to just compress memory, rather than sending it out to mass storage. But more and more programs are using more and more memory. So most of the freezes I've seen are related to long-running processes, typically Apple's processes used for things like curating photographs or background indexing of the SSD, waking up, having lots of memory decompressed, making the program you are using have its memory compressed, and then the scheduler changing its mine and giving your program memory. One of the related problems is that the Mach process scheduler doesn't seem to be as memory and swapping aware as it should be.

Your question is about how to diagnose this, so here's what I do:

  1. First thing I do is set my system clock to count every second so I can always look up at the menu bar and see if the computer has crashed.
  2. Next, I set up a program that does a ps aux every second and stores the result in another file.
  3. I use the computer until it freezes.
  4. Then I look at the relevant ps aux to see which process was taking up the most memory or the most CPU.

If you are pretty sure you have identified the process, you can STOP it without killing it. See if this makes the problem go away.

Once you've identified the culprit, you have a problem. It's typically an Apple process, not your own, not a third-party driver, not anything that you have control over. Here are some of the things I've tried:

  1. Create a new user on your computer and try using it without copying over all of your files. Does the problem go away? If so, it's either that your profile is corrupted or, more likely, a file in your profile is causing the problem. Now you can slowly copy things into the new profile until you have identified the problem.

  2. Sometimes I've found individual files that causes the full-text indexing program to blow up the amount of memory it needs or to crash. I delete those files and the problem goes away.

  3. Sometimes I just wipe the computer and restore my files. That works.

Good luck. This is annoying and it's almost certainly apple's fault.