5

I have two MacBooks, one with a fresh OS X install and one with an older install. The older one has a kernel_task taking 1.52 GB of RAM. The newer one—416 MB. These aren't identical machines or anything, but I am curious about the magnitude of the discrepancy and what contributes to it. Is there any way to inspect what comprises the kernel_task footprint, ideally without needing to experimentally uninstall various applications/services at a time?

I did try:

$ kextstat
Index Refs Address            Size       Wired      Name (Version) <Linked Against>
    1   77 0xffffff7f80757000 0x686c     0x686c     com.apple.kpi.bsd (12.6.0)
    2    6 0xffffff7f80742000 0x46c      0x46c      com.apple.kpi.dsep (12.6.0)
    3  101 0xffffff7f80761000 0x1b7ec    0x1b7ec    com.apple.kpi.iokit (12.6.0)
    4  107 0xffffff7f8074d000 0x99f8     0x99f8     com.apple.kpi.libkern (12.6.0)
    5   94 0xffffff7f80743000 0x88c      0x88c      com.apple.kpi.mach (12.6.0)
    6   41 0xffffff7f80744000 0x502c     0x502c     com.apple.kpi.private (12.6.0)
    7   64 0xffffff7f8074a000 0x23cc     0x23cc     com.apple.kpi.unsupported (12.6.0)
    8    0 0xffffff7f814b2000 0x41000    0x41000    com.apple.kec.corecrypto (1.0) <7 6 5 4 3 1>
    9   22 0xffffff7f807f3000 0x9000     0x9000     com.apple.iokit.IOACPIFamily (1.4) <7 6 4 3>
   10   31 0xffffff7f808b2000 0x29000    0x29000    com.apple.iokit.IOPCIFamily (2.8) <7 6 5 4 3>
   11    2 0xffffff7f81e79000 0x5a000    0x5a000    com.apple.driver.AppleACPIPlatform (1.8) <10 9 7 6 5 4 3 1>
   12    1 0xffffff7f80acf000 0xe000     0xe000     com.apple.driver.AppleKeyStore (28.21) <7 6 5 4 3 1>
   13    5 0xffffff7f8077d000 0x25000    0x25000    com.apple.iokit.IOStorageFamily (1.8) <7 6 5 4 3 1>
   14    0 0xffffff7f80e1b000 0x19000    0x19000    com.apple.driver.DiskImages (345) <13 7 6 5 4 3 1>
   15    0 0xffffff7f81b60000 0x2e000    0x2e000    com.apple.driver.AppleIntelCPUPowerManagement (214.0.0) <7 6 5 4 3 1>
   16    0 0xffffff7f8075e000 0x3000     0x3000     com.apple.security.TMSafetyNet (7) <7 6 5 4 2 1>
   17    2 0xffffff7f80854000 0x4000     0x4000     com.apple.kext.AppleMatch (1.0.0d1) <4 1>
   18    1 0xffffff7f80858000 0x11000    0x11000    com.apple.security.sandbox (220.4) <17 7 6 5 4 3 2 1>
   19    0 0xffffff7f80869000 0x6000     0x6000     com.apple.security.quarantine (2.1) <18 17 7 6 5 4 2 1>
   20    0 0xffffff7f81eea000 0x8000     0x8000     com.apple.nke.applicationfirewall (4.0.39) <7 6 5 4 3 1>
   21    0 0xffffff7f81e4d000 0x3000     0x3000     com.apple.driver.AppleAPIC (1.7) <4 3>
   22    3 0xffffff7f80d05000 0x4000     0x4000     com.apple.iokit.IOSMBusFamily (1.1) <5 4 3>
   23    0 0xffffff7f81ed9000 0x7000     0x7000     com.apple.driver.AppleACPIEC (1.8) <22 11 9 5 4 3>
   24    0 0xffffff7f81925000 0x4000     0x4000     com.apple.driver.AppleSMBIOS (1.9) <7 4 3>
   25    0 0xffffff7f81bb0000 0x3000     0x3000     com.apple.driver.AppleHPET (1.8) <9 7 5 4 3>
   26    6 0xffffff7f80add000 0x6d000    0x6d000    com.apple.iokit.IOHIDFamily (1.8.1) <12 7 6 5 4 3 2 1>
   27    0 0xffffff7f81ee3000 0x4000     0x4000     com.apple.driver.AppleACPIButtons (1.8) <26 11 9 7 6 5 4 3 1>
   28    0 0xffffff7f81951000 0x8000     0x8000     com.apple.driver.AppleRTC (1.5) <9 5 4 3 1>
   29    1 0xffffff7f81e20000 0x5000     0x5000     com.apple.driver.AppleEFIRuntime (2.0) <7 6 5 4 3>
   30    0 0xffffff7f8192b000 0x8000     0x8000     com.apple.driver.AppleSmartBatteryManager (161.0.0) <22 9 5 4 3 1>
   31    0 0xffffff7f81e25000 0xa000     0xa000     com.apple.driver.AppleEFINVRAM (2.0) <29 7 6 5 4 3>
   32    0 0xffffff7f81b5b000 0x3000     0x3000     com.apple.driver.AppleIntelCPUPowerManagementClient (214.0.0) <7 6 5 4 3 1>
   33   15 0xffffff7f80a4e000 0x5e000    0x5e000    com.apple.iokit.IOUSBFamily (635.4.0) <10 7 5 4 3 1>
   34    0 0xffffff7f80be7000 0x18000    0x18000    com.apple.driver.AppleUSBEHCI (621.4.6) <33 10 7 5 4 3 1>
   35    0 0xffffff7f80b6d000 0x1d000    0x1d000    com.apple.driver.AppleUSBXHCI (635.4.0) <33 10 7 5 4 3 1>
   36    2 0xffffff7f81024000 0x16000    0x16000    com.apple.iokit.IOAHCIFamily (2.5.1) <5 4 3 1>
   37    0 0xffffff7f81e52000 0x1a000    0x1a000    com.apple.driver.AppleAHCIPort (2.6.6) <36 10 5 4 3 1>
   38    0 0xffffff7f81938000 0x12000    0x12000    com.apple.driver.AppleSDXC (1.4.3) <13 10 5 4 3 1>
   39    3 0xffffff7f80a0f000 0x2b000    0x2b000    com.apple.iokit.IONetworkingFamily (3.0) <7 6 5 4 3 1>
   40    1 0xffffff7f8106e000 0x68000    0x68000    com.apple.iokit.IO80211Family (530.5) <39 7 6 5 4 3 1>
   41    0 0xffffff7f810dd000 0x1f9000   0x1f9000   com.apple.driver.AirPort.Brcm4331 (615.20.17) <40 39 10 7 5 4 3 1>
   42    1 0xffffff7f80acc000 0x3000     0x3000     com.apple.iokit.IOUSBUserClient (630.4.4) <33 7 5 4 3 1>
   43    0 0xffffff7f80bcb000 0x15000    0x15000    com.apple.driver.AppleUSBHub (635.4.0) <33 5 4 3 1>
   44    4 0xffffff7f80c1c000 0xbb000    0xbb000    com.apple.iokit.IOThunderboltFamily (2.7.7) <5 4 3 1>
   45    0 0xffffff7f81863000 0x16000    0x16000    com.apple.driver.AppleThunderboltNHI (1.9.2) <44 10 9 5 4 3 1>
   46    0 0xffffff7f8104a000 0x17000    0x17000    com.apple.iokit.IOAHCIBlockStorage (2.3.5) <36 13 6 5 4 3 1>
   47    0 0xffffff7f817a6000 0x3000     0x3000     com.apple.driver.XsanFilter (404) <13 5 4 3 1>
   48    0 0xffffff7f81502000 0x9000     0x9000     com.apple.BootCache (34) <7 6 5 4 3 1>
   49    0 0xffffff7f81e11000 0x4000     0x4000     com.apple.AppleFSCompression.AppleFSCompressionTypeZlib (1.0.0d1) <6 4 3 2 1>
   50    0 0xffffff7f81e17000 0x3000     0x3000     com.apple.AppleFSCompression.AppleFSCompressionTypeDataless (1.0.0d1) <7 6 4 3 2 1>
   52    1 0xffffff7f80b66000 0x7000     0x7000     com.apple.driver.AppleUSBComposite (621.4.0) <33 4 3 1>
   53    0 0xffffff7f813cf000 0xc4000    0xc4000    com.apple.driver.CoreStorage (296.18.2) <13 7 6 5 4 3 1>
   54    0 0xffffff7f80bc4000 0x7000     0x7000     com.apple.driver.AppleUSBMergeNub (621.4.6) <52 33 4 3 1>
   56    3 0xffffff7f80b5d000 0x9000     0x9000     com.apple.iokit.IOUSBHIDDriver (623.4.0) <33 26 5 4 3 1>
   57    0 0xffffff7f817da000 0x4000     0x4000     com.apple.driver.AppleUSBTCKeyboard (237.1) <56 33 26 7 6 5 4 3 1>
   59    0 0xffffff7f817e5000 0x13000    0x13000    com.apple.driver.AppleUSBMultitouch (237.3) <56 33 26 6 5 4 3 1>
   60    0 0xffffff7f81855000 0x5000     0x5000     com.apple.driver.AppleThunderboltPCIDownAdapter (1.3.2) <44 10 5 4 3>
   61    1 0xffffff7f8187d000 0x9000     0x9000     com.apple.driver.AppleThunderboltDPAdapterFamily (2.5.0) <44 10 9 5 4 3>
   62    0 0xffffff7f81886000 0x6000     0x6000     com.apple.driver.AppleThunderboltDPInAdapter (2.5.0) <61 44 10 9 5 4 3>
   63    0 0xffffff7f817e0000 0x3000     0x3000     com.apple.driver.AppleUSBTCButtons (237.1) <56 33 26 7 6 5 4 3 1>
   64   15 0xffffff7f80dc4000 0x38000    0x38000    com.apple.iokit.IOGraphicsFamily (2.3.7) <10 7 5 4 3>
   65    2 0xffffff7f81914000 0xe000     0xe000     com.apple.driver.AppleSMBusController (1.0.11d1) <22 10 9 5 4 3>
   66    0 0xffffff7f819bb000 0xd000     0xd000     com.apple.driver.AppleMCCSControl (1.1.11) <65 64 10 9 7 5 4 3 1>
   67    8 0xffffff7f80e07000 0x12000    0x12000    com.apple.iokit.IONDRVSupport (2.3.7) <64 10 7 5 4 3>
   68    1 0xffffff7f81df1000 0x5000     0x5000     com.apple.driver.AppleBacklightExpert (1.0.4) <67 64 10 5 4 3>
   69    0 0xffffff7f81e45000 0x5000     0x5000     com.apple.driver.AppleBacklight (170.3.5) <68 67 64 10 5 4 3>
   70    2 0xffffff7f81be1000 0xc000     0xc000     com.apple.iokit.IOHDAFamily (2.4.7fc4) <5 4 3 1>
   71    1 0xffffff7f81c18000 0x19000    0x19000    com.apple.driver.AppleHDAController (2.4.7fc4) <70 64 10 7 6 5 4 3 1>
   72    0 0xffffff7f81ae6000 0x61000    0x61000    com.apple.driver.AppleIntelFramebufferCapri (8.1.6) <64 10 9 7 6 5 4 3 1>
   73    5 0xffffff7f80d74000 0xa000     0xa000     com.apple.driver.IOPlatformPluginFamily (5.4.1d13) <9 7 6 5 4 3>
   74    5 0xffffff7f807fc000 0xf000     0xf000     com.apple.driver.AppleSMC (3.1.5d4) <9 7 5 4 3>
   75    1 0xffffff7f80d7e000 0xe000     0xe000     com.apple.driver.X86PlatformPlugin (1.0.0) <74 73 33 9 7 6 5 4 3 1>
   78    1 0xffffff7f81ddd000 0x3000     0x3000     com.apple.driver.AppleGraphicsControl (3.4.5) <67 64 10 9 7 5 4 3 1>
   79    0 0xffffff7f81de0000 0xc000     0xc000     com.apple.driver.ApplePolicyControl (3.4.5) <78 67 64 10 9 7 5 4 3 1>
   80    0 0xffffff7f813c9000 0x5000     0x5000     com.apple.Dont_Steal_Mac_OS_X (7.0.0) <74 7 4 3 1>
   81    2 0xffffff7f80efb000 0x9a000    0x9a000    com.apple.iokit.IOBluetoothFamily (4.1.7f5) <33 7 5 4 3 1>
   82    0 0xffffff7f80cf1000 0x12000    0x12000    com.apple.iokit.IOSurface (86.0.4) <7 5 4 3 1>
   83    1 0xffffff7f81a27000 0x4b000    0x4b000    com.apple.iokit.IOAcceleratorFamily (74.18) <67 64 10 7 5 4 3 1>
   84    0 0xffffff7f81a7d000 0x49000    0x49000    com.apple.driver.AppleIntelHD4000Graphics (8.1.6) <83 67 64 10 7 5 4 3 1>
   85    0 0xffffff7f80d94000 0x3000     0x3000     com.apple.driver.AppleSMCPDRC (1.0.0) <73 10 6 4 3>
   87    0 0xffffff7f80a41000 0x7000     0x7000     com.apple.iokit.IOUserEthernet (1.0.0d1) <39 6 5 4 3 1>
   88    2 0xffffff7f80eb6000 0xe000     0xe000     com.apple.kext.OSvKernDSPLib (1.12) <5 4>
   89    5 0xffffff7f80ec4000 0x2f000    0x2f000    com.apple.iokit.IOAudioFamily (1.9.2fc7) <88 5 4 3 1>
   90    1 0xffffff7f81c31000 0xba000    0xba000    com.apple.driver.DspFuncLib (2.4.7fc4) <89 88 6 5 4 3 1>
   91    0 0xffffff7f81cf4000 0x8b000    0x8b000    com.apple.driver.AppleHDA (2.4.7fc4) <90 89 71 70 67 64 6 5 4 3 1>
   94    0 0xffffff7f8080d000 0x7000     0x7000     com.apple.driver.SMCMotionSensor (3.0.3d1) <74 5 4 3>
   95    0 0xffffff7f81911000 0x2000     0x2000     com.apple.driver.AppleSMBusPCI (1.0.11d1) <10 5 4 3>
   96    0 0xffffff7f819f2000 0x3000     0x3000     com.apple.driver.AppleLPC (1.6.3) <73 10 5 4 3>
   97    0 0xffffff7f81bf0000 0x16000    0x16000    com.apple.driver.AppleMikeyDriver (2.4.7fc4) <65 9 5 4 3 1>
   98    1 0xffffff7f80fca000 0x1b000    0x1b000    com.apple.iokit.IOBluetoothHostControllerUSBTransport (4.1.7f5) <33 10 9 7 5 4 3 1>
   99    0 0xffffff7f80fe5000 0x8000     0x8000     com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport (4.1.7f5) <98 33 10 9 7 5 4 3>
  102    0 0xffffff7f817fb000 0x5000     0x5000     com.apple.driver.AppleUpstreamUserClient (3.5.12) <64 10 9 7 5 4 3 1>
  103    0 0xffffff7f81909000 0x5000     0x5000     com.apple.driver.AppleSMCLMU (2.0.3d0) <74 64 5 4 3>
  104    0 0xffffff7f819b0000 0x3000     0x3000     com.apple.driver.AppleMikeyHIDDriver (124) <26 7 4 3 1>
  105    1 0xffffff7f80d0e000 0xe000     0xe000     com.apple.iokit.IOSerialFamily (10.0.6) <7 6 5 4 3 1>
  106    0 0xffffff7f80ea6000 0xa000     0xa000     com.apple.iokit.IOBluetoothSerialManager (4.1.7f5) <105 7 5 4 3 1>
  107    0 0xffffff7f80fb5000 0x9000     0x9000     com.apple.driver.IOBluetoothA2DPAudioDriver (4.1.7f5) <89 81 5 4 3 1>
  108    0 0xffffff7f80fa4000 0xa000     0xa000     com.apple.driver.IOBluetoothSCOAudioDriver (4.1.7f5) <89 81 5 4 3>
  109    0 0xffffff7f81518000 0x5000     0x5000     com.apple.driver.AudioAUUC (1.60) <89 64 10 9 7 5 4 3 1>
  110    0 0xffffff7f80d8c000 0x6000     0x6000     com.apple.driver.X86PlatformShim (1.0.0) <75 74 73 7 4 3>
  111    0 0xffffff7f81dc3000 0x12000    0x12000    com.apple.driver.AGPM (100.13.14) <73 67 64 10 5 4 3>
  112    0 0xffffff7f819a9000 0x4000     0x4000     com.apple.driver.ApplePlatformEnabler (2.0.7d2) <7 5 4 3>
  113    0 0xffffff7f80870000 0x2b000    0x2b000    com.apple.iokit.IOSCSIArchitectureModelFamily (3.5.6) <5 4 3 1>
  114    0 0xffffff7f81f07000 0x12000    0x12000    com.intel.kext.intelhaxm (1.1.1) <7 5 4 3 1>
  115    2 0xffffff7f80817000 0x5000     0x5000     com.apple.kext.triggers (1.0) <7 6 5 4 3 1>
  116    0 0xffffff7f8150d000 0x9000     0x9000     com.apple.filesystems.autofs (3.0) <115 7 6 5 4 3 1>
  117    3 0xffffff7f81f19000 0x58000    0x58000    org.virtualbox.kext.VBoxDrv (4.3.22) <7 5 4 3 1>
  118    0 0xffffff7f81f71000 0x8000     0x8000     org.virtualbox.kext.VBoxUSB (4.3.22) <117 42 33 7 5 4 3 1>
  119    0 0xffffff7f81f79000 0x5000     0x5000     org.virtualbox.kext.VBoxNetFlt (4.3.22) <117 7 5 4 3 1>
  120    0 0xffffff7f81f7e000 0x6000     0x6000     org.virtualbox.kext.VBoxNetAdp (4.3.22) <117 5 4 1>
  124    0 0xffffff7f81f8d000 0xd000     0xd000     com.apple.nke.asp_tcp (7.1.0) <7 6 5 4 3 1>
  125    1 0xffffff7f81f9a000 0x11000    0x11000    com.apple.security.SecureRemotePassword (1.0) <4 1>
  126    0 0xffffff7f81fab000 0x4f000    0x4f000    com.apple.filesystems.afpfs (10.0) <125 7 6 5 4 3 1>
  127    0 0xffffff7f81ffa000 0x33000    0x33000    com.apple.filesystems.smbfs (1.8.4) <115 7 6 5 4 3 1>

$ kextstat | grep -v com.apple
Index Refs Address            Size       Wired      Name (Version) <Linked Against>
  114    0 0xffffff7f81f07000 0x12000    0x12000    com.intel.kext.intelhaxm (1.1.1) <7 5 4 3 1>
  117    3 0xffffff7f81f19000 0x58000    0x58000    org.virtualbox.kext.VBoxDrv (4.3.22) <7 5 4 3 1>
  118    0 0xffffff7f81f71000 0x8000     0x8000     org.virtualbox.kext.VBoxUSB (4.3.22) <117 42 33 7 5 4 3 1>
  119    0 0xffffff7f81f79000 0x5000     0x5000     org.virtualbox.kext.VBoxNetFlt (4.3.22) <117 7 5 4 3 1>
  120    0 0xffffff7f81f7e000 0x6000     0x6000     org.virtualbox.kext.VBoxNetAdp (4.3.22) <117 5 4 1>

The largest entry is the Airport entry clocking in at a size of 2068480 bytes (these are bytes according to man kextstat), i.e. not big.

4

I would run the sysdiagnose command to generate snapshots on both systems. It's going to log far more data than you need, but it will show memory maps of why exactly the memory allocation has gotten to the place where it is.

Then, if you set up two test accounts on each Mac with nothing in them - set both to be the auto-log-in user and reboot both.

Grab a third and fourth sysdiagnose from the cleanly rebooted systems. You should find a stable, reproducable kernel memory allocation when freshly booted and no apps started. Not that both systems will have the same initial kernel allocations - just that they should be stable across reboots.

Inside the tar.gz files sysdiagnose generates, start with comparing the footprint-all.txt files and see which processes are causing the largest Kernel Memory allocations. The last few lines of that file are also helpful in seeing the balance between kernel allocations and user memory allocations/classes.

You could probably just use the footprint tool, but I'm lazy and let sysdiagnose get me all the logs and then pick/choose the parts I need for a specific task. I also use heap and vmmap often on daemons and user processes, but using it on kernel_task might not be as useful.

3

Use zprint -t (Lion) or sudo zprint -t (Mountain Lion and later) (man zprint) to show information about kernel zones

Example (i skipped about 160 lines):

zprint -t
                   elem      cur         max       cur       max       cur alloc alloc          
zone name          size     size        size     #elts     #elts     inuse  size count        Total Allocs
-----------------------------------------------------------------------------------------------------------
zones               544      93K        102K       176       192       167    8K    15                  88K
vm.objects          224   62134K      66430K    284043    303680    283180   16K    73   C         2702161K
vm.object.hash.en$   40    9941K      13122K    254490    335923    238354    4K   102   C          130659K
maps                232      43K         40K       192       176       180    8K    35               27576K
....
....
VM.map.entries       80    6100K       7776K     78080     99532     76888   20K   256   C         1141452K
kernel_stacks     16384    2448K       3200K       153       200       139   16K     1   C           52144K
page_tables        4096  138280K 4293389860K     34570    654217     34570    4K     1   C          595852K
kalloc.large      72308   31705K      32310K       449       457       449   70K     1            13005729K
TOTAL SIZE   = 920734440
TOTAL USED   = 895302860
TOTAL ALLOCS = 310758214530
  • My "total size" is showing 726412624, half the 1.5GB. Do you know why / what the relationship is? – Yang Feb 26 '15 at 1:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .