How to debug an out-of-control “kernel_task” process

activity-monitorbatterysnow leopard

Just recently I noticed my battery life having a pretty significant drop and the "kernel_task" process using quite a bit of CPU (a constant 1-6% on my 2.8ghz dual-core i7, 2010 MBP). Obviously I think the kernel_task's CPU usage is contributing to the battery drop and I need to find out why.

Searching Google, it seems kernel_task is OS X's version of Windows's "svchost.exe" – the notorious do-everything process that you can't ever truly debug, you have to just manually flip switches until one of them works.

Is there any way I can more easily get to the bottom of the out-of-control kernel_task activity? I haven't tried a reboot because if that does "fix" it, it doesn't really fix the underlying problem.

Activity Monitor shows the CPU usage. When I hit Inspect, it shows 77 threads, 2 ports, hours and hours of CPU time, Context Switches going up about 400 per second, and Mach Messages In and Out both going up at about 6,000 per second.

How can I somehow inspect or monitor this kernel_task process and figure out what's actually using all this power?

(note: my current suspects are the recent 10.6.7 update, Firefox update from 4 beta 10 to RC, or ScreenResX – these are all things I've done recently that I can think of)

Best Answer

I had a similar question about how to identify files and programs connected to kernal_task using the following terminal command:

kextstat -l -k | awk '{n = sprintf("%d", $4); print n, $6}' | sort -n

This will display various kexts and the memory associated with them. For example, 6184960 com.apple.driver.AirPort.Brcm4360 is a big hog for me, but I can't do much about it if I want to use wifi.

One of the suggestions I received was to look up all non-Apple kexts are taking up memory by piping the above to grep -v com.apple. It's possible that some non-Apple programs are using up your resources. You should be able to remove those without breaking anything.

The age old solution of course is to restart your computer. Sometimes that's all it takes to set processes back to their normal levels of CPU usage.