I'd say that about 80% to 90% of the time kernel panics are due to a hardware problem. In order of likelihood, that problem is usually:
- bad third party RAM
- a problematic USB hub
- a peripheral that your Mac doesn't like for some reason, usually a third party peripheral (sometimes just a poorly attached cable, or a bad cable, is the problem)
If you have very recently added new software, especially something that alters the system at a low level, such as anti-virus software, or something that changes the look and/or function of the Mac interface, I would suspect that first. Uninstall that software and see if things get better. (This type of software typically requires an uninstaller to completely disable. Just dragging the application, or the application's folder, to the Trash won't disable it.) I'd go so far as to say that if you are running commercial fully interactive anti-virus software that the first thing that you should try is fully uninstalling it.
If that isn't it, I would restart the Mac with the Shift key held down (invoking a Safe Boot, with all kernel extensions disabled) and see if the problem is gone while running in Safe mode. If the problem is gone while in Safe mode, the Kernel Panics are probably due to a software problem. If it persists while in Safe mode, the problem is most likely hardware related.
To test for hardware problems, you can run Apple Diagnostics:
Apple Diagnostics, formerly known as Apple Hardware Test, can check your Mac for hardware issues.
Unfortunately, it's easily possible to have a hardware problem that this utility doesn't identify.
If you suspect a hardware problem, the next thing that I would do is to shut down your Mac, uninstall all peripherals other than the Apple-supplied keyboard and mouse, restart and see if that helps. If it does, you can re-attach one peripheral at a time, restarting each time, until you isolate the offending peripheral.
If that isn't a solution, you should test your RAM with this free utility:
Portland area Mac IT, Onsite and Consulting Services; Software and Scripts for iOS and OS X
If your RAM is okay, you should then test your hard drive:
DriveDX (free demo)
DriveDx - the most advanced drive health (S.M.A.R.T.) diagnostics and monitoring utility. Save yourself the data loss and downtime that is associated with unexpected SSD and HDD failures. Don't worry about losing your important data, music, and photographs.
Any time it shows any drive errors in yellow or red, it is correlated with a drive that's questionable.
Helpful Web sites:
"Tutorial: Avoiding and eliminating Kernel panics"
Tutorial: Avoiding and eliminating Kernel panics
About kernel panics
Learn what to do if your computer restarts or shuts down unexpectedly, or you get a message that your computer restarted or shut down because of a problem.
How to troubleshoot a kernel panic
Most of the time, if something crashes on your Mac, it's just one app. But other times, your whole system goes down thanks to a kernel panic. When that happens, here's what to do.
How to Recognize and Troubleshoot Kernel Panics
Recognition, immediate action including capturing the panic log, discovering clues as to cause, further investigations to diagnose and address the cause.