How can I isolate macOS 10.14.6 Mojave freezing 1-2 seconds every few minutes except for sound and the mouse?
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:
- 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.
- Next, I set up a program that does a
ps aux
every second and stores the result in another file. - I use the computer until it freezes.
- 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:
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.
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.
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.
Does your Macbook have a physical HD or a SSD? In my experience, these sound like the symptoms of imminent HD failure: your computer is trying to read/write to disk, but it can't because the HD is accessing a bad sector and can't read/write to it, so everything freezes until the HD responds.
If you actually have a physical HD, the way to check this would be to check the SMART status. The "standard" way to do this would be using Disk Utility; unfortunately, it won't tell you much. In most OSes (Windows too), the OS-level tools to check on hard drives will just tell you "SMART status: passed"... right up to the moment the HD fails.
In my experience, the only reliable way to check the SMART status (including the most important stats: bad sectors, reallocated sectors...) in macOS is to use Homebrew to install "smartmontools", an Unix command-line program to check the SMART status of your HD. Forther details in this question:
How do I get detailed SMART disk information on OS X (Mavericks or later)
If you do this and see that stats like "Uncorrectable Sector Count" are higher than 0... backup your data immediately. And change the HD.
Let's start with some basic troubleshooting steps and we'll see how far we get.
The first thing I would do now is test your MBP in Safe Mode.
Boot into Safe Mode
Follow these steps to boot your MBP into Safe Mode:
- Fully shut down your Mac
- Restart your Mac
- Immediately press the Shift key and keep it down
- Let go of the Shift key when you see the login window (NOTE: If you have FileVault enabled you may need to log in twice).
- Now use your MBP in Safe Mode until it starts showing the freezing symptom again or until you're satisfied it's not going to
- Exit Safe Mode by restarting your Mac as normal
- Once again, test to see if your MBP still freezes
Now, if you find that your MBP:
- works fine while in Safe Mode, but not when booted normally, then it's likely to be a login item, corrupted font, or kernel extension). If so, read on further below.
- still freezes, then it's time to skip ahead to resetting SMC, NVRAM and potentially testing your hardware. If so, let me know your exact model of MBP and I'll add the steps to this answer.
Investigating login items, fonts, and kernel extensions
Let's start with Login Items:
- Startup normally
- Go to System Preferences > Users & Groups
- Select the Login Items tab
- Take a note of your Login Items
- Now remove all of them by highlighting them and clicking on the - button below
- Restart your computer
Now your Mac will boot up without those login items loading. Test to see if you can use your Mac without it freezing:
- If you can, you know one (or more) of the Login items were causing the problem. You can then add them back in one by one until you've identified the culprit. Problem solved.
- If the problem does persist, it's either a problem with fonts you've installed yourself or with a 3rd party kernel extension. A little more info below:
Fonts:- You can remove any of the fonts you've installed yourself to see if this makes a difference.
Kernel Extensions:- You can open Terminal (found within your Utilites folder) and enter the following command:
kextstat | grep -v com.apple
The above command will list 3rd party kernel extensions (you may need to stretch the Terminal window so it's easier to read). Look for anything you don't remember installing, or something that belongs to software you've removed, or just anything that looks out of place. Remember though, this is a list of 3rd party kernel extensions and therefore any of them could be causing the problem.