Apple - How to investigate high kernel task memory usage?
There are many things that go wrong with high kernel task usage. Usually this is related to faulty or heavy process which overusing system resources (such as indexing storage, running VMs, too many tabs in the web browser or some other background processes).
Here are some methods which help to investigate OS X kernel usage issues:
Console.appand check on 'All Messages' to see if anything unusual currently is happening.
Use Activity Monitor to read system memory and determine how much CPU, RAM and Disk is being used.
topin Terminal and hold Space to refresh - easier to find the cause problem (swapins/swapouts/disks?).
sudo fs_usagein Terminal to report system calls and page faults related to filesystem activity in real-time (I think this is the best option from all other). Then hit Control-C to stop it.
Action: Consider killing apps which appears frequently on the list, but you're not using them.
Learn more at: How do I debug an out-of-control “kernel_task” process?
syscallbyproc.d), wait a bit, hit Control-C. Now check which process generated the most system calls in that given time (last column) and if you recognise it, consider kill it. If not, Google it and learn more about it.
sysdiagnosecommand (can be triggered by hitting Shift-Control-⌥-⌘-. (period) to quickly gather system-wide diagnostic information helpful in investigating system memory/performance issues (will appear in
/var/tmp) either by you or Apple guys. During analysis, try to not do anything, when done - consider uncompressing the generated file and analyse the logs.
See: How do you get system diagnostic files from OS X?
footprintto gather detailed memory information on a per-VM-region type level and swapped bytes:
sudo footprint -a
sudo footprint -all -categories -swapped -collapseSharing
spindumpto profile entire system, it'll generate
/tmp/spindump.txtfile (including kernel and its extensions).
vm_statto show virtual memory statistics. E.g.
vm_stat 1 # to display every second.
zprintto check information about kernel usage, it's possible by:
sudo zprint -t -s | head -n20
It'll show the most wasting kernel zones.
newproc.dto snoop new processes as they are executed,
sudo newproc.d sudo creatbyproc.d
Note: On newer OS X (10.11 or above) this may not work when integrity protection is enabled (check by
sar- system activity reporter which can sample and report various cumulative statistic counters maintained by the operating system.
For more useful debugging tools, check for dtrace scripts (
grep dtrace /usr/bin/*). If you know the faulty process which causing the problem, you may use
dtruss to debug it.
Here are some suggestions which can help you with the operating system issues.
Free up some inactive memory. In order to do this, you've to flush cache first and force disk cache to be purged:
sync && sudo purge
sync- force completion of pending disk writes (flush cache)
purge- force disk cache to be purged (flushed and emptied)
Its function is basically to terminate all the I/O pending operations which are using disk cache and then to free all the occupied disk cache, so it should free disk space to ease paging out and swapping out of main memory. It is safe to use, as it does not affect anonymous memory that has been allocated through malloc, vm_allocate, etc.
Use some 3rd party apps to clear up some overused memory such as iBoostUp, SystemPal, etc.
You may also disable temporary Spotlight:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
And consider other services by:
sudo launchctl list | grep ^[0-9] sudo launchctl bslist | grep ^A
I had a very similar issue after replacing my LCD screen on a late 2012 iMac. Fan was running at high RPM and had high CPU Kernel_task usage. I narrowed it down to a Temperature sensor you must move from the old LCD screen to the new replacement screen. if you forget to do so the CPU speed and Kernel_task are affected slowing down your system.