Most crashes on a Mac affect just one application. But you may encounter a type of system-wide crash that brings down your entire Mac: a kernel panic. When this occurs, there's no warning and no way to save your work or do anything else without restarting. And, because kernel panics can have many different causes, diagnosing the problem and preventing its recurrence are difficult.
How do you know if it's a kernel panic?
If you're running OS X 10.7 Lion or earlier, kernel panics usually result in your screen dimming from top to bottom, and a message appearing in several languages telling you that you must restart your Mac (by holding down the power button for several seconds to turn it off, and then pressing it again to turn it back on).
Starting in OS X 10.8 Mountain Lion, OS X automatically restarts when you have a kernel panic, and then displays a similar-looking message for 60 seconds (or until you press a key) telling you that your Mac was restarted because of a problem. (If the kernel panic repeats every time your Mac restarts, OS X will give up after five tries and shut your Mac down.)
As Apple notes on its support page about kernel panics, something as random and fleeting as malformed network packets can potentially cause a kernel panic. So, if you experience this problem just once, or only rarely, just restart, get back to work, and forget about it.
But if you see a kernel panic frequently (Apple apparently defines "frequently" as "more than once every few weeks"), you should take additional troubleshooting steps. I suggest a slightly different sequence of steps than what Apple outlines.
First things first
If you're running OS X 10.8 or later, immediately after your Mac restarts on its own you'll see a dialog box asking whether you want to reopen the apps that were open before the crash. Click Open; if the kernel panic recurs, one of the running apps is a likely culprit, so click Cancel the next time around. Either way, another dialog box will ask if you want to see more information and report the problem to Apple. You probably do, so click Report. You may be unable to make heads or tails of the technical details, but glance over them and then click OK to send the report to Apple.
If you're seeing repeated kernel panics, try the following things until they go away.
Do a safe boot: Restart your Mac and hold down the Shift key until you see the gray Apple logo. Doing so temporarily disables some software that could cause problems and runs some cleanup processes. If the kernel panic doesn't recur, restart again normally.
Update your software: Outdated software is frequently implicated in kernel panics. This may include OS X itself and, very rarely, regular applications. More often it involves low-level software like kernel extensions and drivers. If you've installed software that goes with peripherals (network adapters, audio interfaces, graphics cards, input devices, etc.) or antivirus, file-system, or screen-capture tools, those should be the first you check for newer versions. Choose Software Update from the Apple menu to update OS X, Apple apps, and items purchased from the Mac App Store; for other apps, use a built-in updater or check the developer's website.
Update your firmware: Software Update may also tell you about available updates for your Mac. If so, be sure to install them. You can also check for any firmware updates applicable to your Mac model at http://support.apple.com/kb/ht1237.
Check your disk: Make sure your startup disk has at least 10GB of free space; if it doesn't, delete some files to make room. Next, to find and fix any disk errors, start from another volume, run Disk Utility, select your startup disk, and click Repair Disk. (The easiest way to do this, if you're running OS X 10.7 or later, is to restart and then immediately press and hold Command-R to enter OS X Recovery. If that doesn't work, or if you have an older system, you can start up from a bootable duplicate of your hard disk or OS X install media.)
Check peripherals: If kernel panics continue, shut down your Mac and disconnect everything except the bare minimum (keyboard, pointing device, and display if those aren't built in)--as well as any hardware you've added inside your Mac, such as a graphics card. Turn your Mac back on. If the problem doesn't reappear, repeat the process, reattaching one device at a time. If you see a kernel panic right after connecting a piece of hardware, that may be your culprit.
Check your RAM: Defective RAM can cause kernel panics, and sometimes these defects manifest themselves only after time. If you've added any after-market RAM, try turning off your Mac, removing the extra RAM, and restarting. If that makes the kernel panics disappear, contact the company that sold you the RAM to see about a warranty replacement.
After that, troubleshooting steps get more time-consuming--enough so that if I got to this point without a solution, I'd probably think about making an appointment at the nearest Genius Bar. But if you have a spare hard drive, you can install a fresh copy of OS X on it, boot from that drive, and run Software Update to make sure everything is current. If the kernel panic doesn't occur when running from that drive, you can be pretty sure it's a software issue--some obscure gremlin on your startup disk. Unfortunately, the easiest way to solve it is to start up from another volume (or use OS X Recovery) and reinstall OS X over your existing system, and if that doesn't work, erase the disk and reinstall everything from scratch.
This story, "Troubleshoot a kernel panic" was originally published by Macworld.