Debug kernel_task large memory usage

kernelkernel-extensionsmemorymojave

htop shows kernel_task used 25% of the memory on 8GB memory Macbook Air.

But the sum of the size column of kextstat is only 31830608. I think this number is in bytes? Why is there a difference in memory usage shown by htop and kextstat?

How to debug what threads take the most of the memory?

$ kextstat
Index Refs Address            Size       Wired      Name (Version) UUID <Linked Against>
    1  104 0xffffff7f80c00000 0x9e50     0x9e50     com.apple.kpi.bsd (18.2.0) CA649DFC-CCBE-4E4E-817B-1F57664865F2
    2   10 0xffffff7f81103000 0x3900     0x3900     com.apple.kpi.dsep (18.2.0) 760FD540-C071-4813-9A6D-00A61BC66081
    3  128 0xffffff7f80c2a000 0x21be0    0x21be0    com.apple.kpi.iokit (18.2.0) 189C1E43-7FD6-4C6B-9B4B-F4E10AD163FD
    4    0 0xffffff7f834bb000 0x34b0     0x34b0     com.apple.kpi.kasan (18.2.0) 9D533FF0-5093-4DEC-B9FB-E1812C300F9D
    5  134 0xffffff7f80c0a000 0xd7b0     0xd7b0     com.apple.kpi.libkern (18.2.0) 6395653A-7B06-45F4-A76B-28696B228B20
    6  120 0xffffff7f80c18000 0x3f60     0x3f60     com.apple.kpi.mach (18.2.0) F52D843D-13A6-4347-BB48-01E0BC27CD8D
    7   76 0xffffff7f80c1c000 0xd4c0     0xd4c0     com.apple.kpi.private (18.2.0) 804F8A0C-41CB-4BBF-A5E2-A3A77EB778C9
    8   75 0xffffff7f80c8f000 0x5ea0     0x5ea0     com.apple.kpi.unsupported (18.2.0) B384D29D-4819-4D16-9209-97E046FD279D
    9    9 0xffffff7f81107000 0xb5000    0xb5000    com.apple.kec.corecrypto (1.0) 47FE248D-DF8E-37C4-A3E0-331B39924822 <8 7 6 5 3 1>
   10    2 0xffffff7f819e7000 0x10000    0x10000    com.apple.kec.Libm (1) 52E49F8C-857D-33BB-BEA7-A18B54C19969 <5>
   11    0 0xffffff7f82aaa000 0xa000     0xa000     com.apple.kec.pthread (1) 773007A1-C7A7-3BC1-AEFF-783C4573D21F <8 7 6 5 3 1>
   12   27 0xffffff7f81283000 0x9000     0x9000     com.apple.iokit.IOACPIFamily (1.4) DC1D9290-BFFC-309B-8529-CCB7AB322B1C <8 7 5 3>
   13   35 0xffffff7f80c95000 0x35000    0x35000    com.apple.iokit.IOPCIFamily (2.9) 7DE930EC-AB73-3F5A-9D38-94D5EE90D197 <8 7 6 5 3>
   14    7 0xffffff7f8128c000 0x1e000    0x1e000    com.apple.driver.AppleSMC (3.1.9) CE000030-3AC9-3E7E-8F53-9E8E34EE631A <13 12 8 7 6 5 3 1>
   15    2 0xffffff7f82df9000 0x9c000    0x9c000    com.apple.driver.AppleACPIPlatform (6.1) A5254E14-670B-35BB-8E25-BD9872872275 <14 13 12 8 7 6 5 3 1>
   16    9 0xffffff7f80ff5000 0x30000    0x30000    com.apple.iokit.IONetworkingFamily (3.4) A37DBC4E-D518-3B2B-8736-AE6B88C53D9C <8 7 6 5 3 1>
   17    2 0xffffff7f8102c000 0x2d000    0x2d000    com.apple.iokit.IOTimeSyncFamily (700.7) 0B343114-5139-313E-B3CC-F91E7043ED4F <16 6 5 3 1>
   18    6 0xffffff7f818b7000 0x7000     0x7000     com.apple.iokit.IOReportFamily (47) 6A9FF3E1-E644-3F33-8A44-8B51C44AA67C <6 5 3>
   19    5 0xffffff7f819f7000 0x7000     0x7000     com.apple.driver.IOSlaveProcessor (1) A65C8CC0-7870-3A0A-A15A-B3DCB97526BE <5 3>
   20    3 0xffffff7f83294000 0x18000    0x18000    com.apple.driver.AppleSEPManager (1.0.1) 6ABCCD04-3990-3BA0-9A65-90834B679925 <19 13 9 8 7 6 5 3 1>
   21    1 0xffffff7f812ac000 0x8000     0x8000     com.apple.driver.AppleBusPowerController (1.0) A4F310BD-F588-34FF-A756-7D751A092119 <14 12 7 6 5 3>
   22    7 0xffffff7f812b4000 0x8000     0x8000     com.apple.driver.usb.AppleUSBCommon (1.0) 3C048DDF-4E3F-3603-B95B-5580F5A93F06 <6 5 3 1>
   23   15 0xffffff7f812bc000 0x7b000    0x7b000    com.apple.iokit.IOUSBHostFamily (1.2) 922E7520-229B-3C68-B232-A8727A20D44D <22 21 8 7 6 5 3 1>
   24    3 0xffffff7f82759000 0x1d000    0x1d000    com.apple.driver.KernelRelayHost (1) 1A9D13CD-1AFE-3BCA-AD91-A9109E55FC29 <23 6 5 3>
   25    1 0xffffff7f832c1000 0x3d000    0x3d000    com.apple.driver.AppleCredentialManager (1.0) 67CCF54F-7E44-3643-9E14-00384E048BEA <24 20 19 9 8 7 6 5 3 1>
   26    9 0xffffff7f80fc1000 0x28000    0x28000    com.apple.iokit.IOStorageFamily (2.1) 3732B700-AB0F-3533-9C62-BD2D9DAAB979 <8 7 6 5 3 1>
   27    4 0xffffff7f80c4c000 0x2b000    0x2b000    com.apple.iokit.IOSCSIArchitectureModelFamily (408.200.1) 42F4D8FD-E1EA-30F3-B1FD-2C92580DF6F1 <7 6 5 3 1>
   28    2 0xffffff7f82ad1000 0x19000    0x19000    com.apple.iokit.IOSCSIBlockCommandsDevice (408.200.1) E080DC17-ECDC-35EC-B53F-A6B39ABA6A1C <27 26 7 6 5 3 1>
   29    2 0xffffff7f82aee000 0x2d000    0x2d000    com.apple.iokit.IOUSBMassStorageDriver (145.200.2) 3565DEFA-2DBE-3BC4-9348-7F9C83A9858A <27 26 23 7 6 5 3 1>
   30    1 0xffffff7f811bc000 0xa000     0xa000     com.apple.kext.CoreTrust (1) 1666BD0E-9415-3AE8-AB1B-830D5AF90006 <9 5>
   31    6 0xffffff7f811c6000 0x1d000    0x1d000    com.apple.driver.AppleMobileFileIntegrity (1.0.5) 66A1BDE1-514B-3B0D-87DD-8E2B9F110A8C <30 9 8 7 6 5 3 2 1>
   32    1 0xffffff7f82b22000 0x12000    0x12000    com.apple.driver.AppleUSBTDM (456.200.8) 74BF541E-86CA-365D-AC46-F7E5E3EE9B38 <31 29 28 27 26 23 8 7 6 5 3 1>
   33    0 0xffffff7f832fe000 0x69000    0x69000    com.apple.driver.AppleKeyStore (2) 758D945E-E200-313D-AF0B-3055FD8C0AB1 <32 31 25 24 20 19 9 8 7 6 5 3 1>
   34    2 0xffffff7f81818000 0xc000     0xc000     com.apple.driver.AppleEffaceableStorage (1.0) EAE26CBD-418E-3A0D-AAA2-1EA64F624934 <8 6 5 3 1>
   35    0 0xffffff7f83393000 0xc000     0xc000     com.apple.driver.AppleFDEKeyStore (28.30) 29C1A3E4-A9C0-346D-9D25-35D6C64544F1 <34 9 8 7 6 5 3 1>
   36    0 0xffffff7f83791000 0x19000    0x19000    com.apple.driver.DiskImages (493.0.0) 915578EF-4853-3DEB-83D3-6F450EB39D36 <26 8 7 6 5 3 1>
   37    2 0xffffff7f81430000 0x5000     0x5000     com.apple.kext.AppleMatch (1.0.0d1) 71602467-B76C-37CE-84F4-D8A65A0AD05D <5 1>
   38    1 0xffffff7f81435000 0x31000    0x31000    com.apple.security.sandbox (300.0) 82690C64-A0E2-302B-8E37-842CDF4A2A75 <37 31 26 8 7 6 5 3 2 1>
   39    0 0xffffff7f818af000 0x8000     0x8000     com.apple.security.quarantine (3) D28C1B31-13CE-399F-B5D2-8C96E120D52B <38 37 8 7 6 5 2 1>
   40    0 0xffffff7f8378e000 0x2000     0x2000     com.apple.security.TMSafetyNet (8) A2ECA7CA-9E69-3355-A297-B0935F0D02F0 <8 7 6 5 2 1>
   41    0 0xffffff7f83883000 0x9000     0x9000     com.apple.nke.applicationfirewall (190) CB6761CD-ECBE-3DB6-B1E5-2B691968FA0C <8 7 6 5 3 1>
   42    0 0xffffff7f838dc000 0x3000     0x3000     com.apple.driver.AppleAPIC (1.7) FBD2329A-0BC9-3665-8E53-29B7527B54B8 <13 5 3>
   43    9 0xffffff7f811ef000 0x7e000    0x7e000    com.apple.iokit.IOHIDFamily (2.0.0) ECDBC8A9-D637-3FEE-BDA3-94025A03B709 <8 7 6 5 3 2 1>
   44    3 0xffffff7f82ab4000 0x4000     0x4000     com.apple.iokit.IOSMBusFamily (1.1) BC6BE924-53E3-318A-A1B7-B896FA559717 <6 5 3>
   45    0 0xffffff7f82e9e000 0x7000     0x7000     com.apple.driver.AppleACPIEC (6.1) BD7C0EE5-AC26-3DB1-BAFB-80A2B54F54D6 <44 43 18 15 12 8 7 6 5 3 1>
   46    0 0xffffff7f83278000 0x4000     0x4000     com.apple.driver.AppleSMBIOS (2.1) 40F3E058-4E0D-3CB9-9E6A-8184CEC32140 <8 5 3>
   47    0 0xffffff7f835a2000 0x3000     0x3000     com.apple.driver.AppleHPET (1.8) 784E4E15-3762-3886-9A11-33AF0A9810C1 <12 8 6 5 3>
   48    0 0xffffff7f82ea8000 0x4000     0x4000     com.apple.driver.AppleACPIButtons (6.1) 537726C7-3FEE-3DB2-B6F6-36A1C6AE2927 <43 18 15 12 8 7 6 5 3 1>
   49    0 0xffffff7f8274e000 0x8000     0x8000     com.apple.driver.AppleRTC (2.0) A7317204-C2D7-37C3-A113-1F828CA5EBA9 <12 8 6 5 3 1>
   50    2 0xffffff7f81358000 0x5000     0x5000     com.apple.driver.AppleEFIRuntime (2.1) 25BD6FAC-7CD2-3006-BB3F-D3EF6B0C4B36 <8 7 6 5 3>
   51    2 0xffffff7f8135d000 0xb000     0xb000     com.apple.driver.AppleEFINVRAM (2.1) E7F595DC-EE23-37F0-BE91-0C67758EA554 <50 8 7 6 5 3 1>
   52    0 0xffffff7f82ab8000 0xb000     0xb000     com.apple.driver.AppleSmartBatteryManager (161.0.0) 3B467A8F-B4EB-3EED-B01A-4DEB584891E8 <44 12 6 5 3 1>
   53    0 0xffffff7f816f9000 0x4000     0x4000     com.apple.driver.AppleUSBHostMergeProperties (1.2) 7ED08F8A-0A4C-3CBC-AAEA-9EC1909A2B59 <5 3 1>
   54    0 0xffffff7f81368000 0x9b000    0x9b000    com.apple.iokit.IOUSBFamily (900.4.2) 102E3905-A575-3F55-A481-6D85E9334AEB <23 22 13 8 6 5 3 1>
   55    0 0xffffff7f81757000 0x5000     0x5000     com.apple.driver.usb.AppleUSBHostPacketFilter (1.0) 821BD275-C5FC-377A-89C8-E1EB39C33F1D <23 22 8 7 6 5 3 1>
   56    1 0xffffff7f81660000 0x55000    0x55000    com.apple.driver.usb.AppleUSBXHCI (1.2) 33335360-2A08-313F-AF2B-5A1D5A6300A0 <23 22 12 8 7 6 5 3 1>
   57    0 0xffffff7f8175c000 0x2f000    0x2f000    com.apple.driver.usb.AppleUSBXHCIPCI (1.2) 04F18AD5-9687-38D8-A12E-BEC01B414281 <56 23 22 13 12 8 7 6 5 3 1>
   59    1 0xffffff7f83221000 0xb000     0xb000     com.apple.driver.AppleIntelLpssGspi (3.0.60) A535A54E-6962-3DFA-B4E5-D8501D58A30A <13 12 8 6 5 3>
   60    1 0xffffff7f8152e000 0x8000     0x8000     com.apple.driver.AppleIntelLpssDmac (3.0.60) 94F91CE7-C1CA-33C0-9E53-39A22137B961 <13 12 6 5 3>
   61    1 0xffffff7f8322c000 0x14000    0x14000    com.apple.driver.AppleIntelLpssSpiController (3.0.60) 13FF93F6-B67D-3388-A833-5E7F967C4424 <60 59 12 6 5 3>
   62    1 0xffffff7f83242000 0x16000    0x16000    com.apple.driver.AppleHSSPISupport (55) 05E38A2E-B65E-31A9-BD10-449A5F5AE0CE <61 12 6 5 3 1>
   63    0 0xffffff7f8389f000 0x3000     0x3000     com.apple.private.KextAudit (1.0) 79EBD7E9-F048-319A-AA1B-9712DA17CC26 <14 8 7 6 5 3>
   64    2 0xffffff7f81a1b000 0x29000    0x29000    com.apple.driver.corecapture (1.0.4) 5760B64C-3ACF-36C8-982C-166D79F1424F <8 7 6 5 3 1>
   65    1 0xffffff7f81a4d000 0x8000     0x8000     com.apple.driver.mDNSOffloadUserClient (1.0.1b8) 4B2F0029-EEA7-31BD-B362-E92CE7324D4F <16 5 3 1>
   66    1 0xffffff7f81a55000 0xfc000    0xfc000    com.apple.iokit.IO80211Family (1200.12.2) 7122958A-02DB-3FFB-B6AE-C0970D228F9D <64 31 16 9 8 7 6 5 3 1>
   67    0 0xffffff7f81b5c000 0x7bd000   0x7bd000   com.apple.driver.AirPort.BrcmNIC (1400.1.1) 43CC7A5C-3C88-3AB4-A8E1-8CEB8576CB05 <66 65 64 16 13 8 7 6 5 3 1>
   68    5 0xffffff7f82623000 0xec000    0xec000    com.apple.iokit.IOThunderboltFamily (6.8.1) 9C90F4A6-3131-3CBF-97ED-F455E6144CDA <6 5 3 1>
   69    0 0xffffff7f838a4000 0x20000    0x20000    com.apple.driver.AppleThunderboltNHI (4.7.6) C79EE552-A3B6-3B82-A43A-0ABA270FE60C <68 13 12 7 6 5 3 1>
   70    0 0xffffff7f832af000 0x5000     0x5000     com.apple.driver.AppleThunderboltPCIDownAdapter (2.1.4) 7BBB5B28-A07C-3E15-9CAA-B1B642A962E6 <68 13 6 5 3 1>
   71    1 0xffffff7f8272e000 0xf000     0xf000     com.apple.driver.AppleThunderboltDPAdapterFamily (5.5.8) D7469734-F3B3-3418-AEF2-67A8E6779E7F <68 12 6 5 3 1>
   72    0 0xffffff7f8273d000 0x6000     0x6000     com.apple.driver.AppleThunderboltDPInAdapter (5.5.8) 76E47BE9-9DBA-3A78-BFBC-D635D04BFA6A <71 68 6 5 3 1>
   73    2 0xffffff7f82f32000 0x1a000    0x1a000    com.apple.iokit.IOAHCIFamily (288) 94FD66DE-F4D9-325B-B89F-535476BFE501 <6 5 3 1>
   74    0 0xffffff7f8376b000 0x14000    0x14000    com.apple.driver.AppleAHCIPort (329.200.2) B9A44F9F-76B9-39E4-B9B2-9971356FCFEA <73 13 6 5 3 1>
   75    0 0xffffff7f82f5c000 0x27000    0x27000    com.apple.iokit.IOAHCIBlockStorage (301.200.2) 7740112A-7D69-38B8-9275-F4BFBFFFD86D <73 51 26 7 6 5 3 1>
   77    1 0xffffff7f818cf000 0x100000   0x100000   com.apple.filesystems.apfs (945.220.38) BE3143DE-BFA2-35A0-A155-D85D83B55242 <34 26 9 8 7 6 5 3 1>
   79    0 0xffffff7f811e3000 0x8000     0x8000     com.apple.AppleSystemPolicy (1.0) 702BC815-3A9C-330E-A3CA-A7B5159F257D <31 8 7 6 5 3 2 1>
   80    1 0xffffff7f81422000 0x8000     0x8000     com.apple.filesystems.hfs.encodings.kext (1) 7578D31E-FCD8-3760-8C50-0D0D9743D61D <8 7 6 5 3 1>
   81    0 0xffffff7f814df000 0xd000     0xd000     com.apple.AppleFSCompression.AppleFSCompressionTypeZlib (1.0.0) AC9EE441-9A4C-3A7C-8B3E-33EB8AC16C77 <7 5 3 2 1>
   82    0 0xffffff7f825e8000 0xe000     0xe000     com.apple.BootCache (40) 2C9E4BE4-59C6-336E-A3EA-A545E9F1DE3D <8 7 6 5 3 1>
   83    0 0xffffff7f83264000 0x3000     0x3000     com.apple.AppleFSCompression.AppleFSCompressionTypeDataless (1.0.0d1) B2A80218-1505-3E31-9F72-ECA1DE80C44B <8 7 5 3 2 1>
   84    1 0xffffff7f835a7000 0x69000    0x69000    com.apple.filesystems.hfs.kext (407.200.4) 2610E305-589A-3FAA-8B66-C198E5A838B3 <80 8 7 6 5 3 1>
   85    2 0xffffff7f834e3000 0xe000     0xe000     com.apple.iokit.IOSerialFamily (11) BFCF0610-7F22-33EC-ABE0-2ED10CDD490F <8 7 6 5 3 1>
   86    0 0xffffff7f837ea000 0x13000    0x13000    com.apple.driver.AppleVirtIO (2.0.9) D1C9646A-2B86-3D43-914C-20AF186B514A <85 26 13 6 5 3 1>
   88    0 0xffffff7f8325b000 0x9000     0x9000     com.apple.driver.AppleHSSPIHIDDriver (55) 503D0D26-1D56-383E-8074-65A9EF8577BF <62 43 6 5 3 1>
   89    0 0xffffff7f833d8000 0xb000     0xb000     com.apple.driver.AppleHIDKeyboard (208) D79556FE-5922-34D7-A0CD-E4D9EAE9DCFB <43 6 5 3>
   90    1 0xffffff7f81a00000 0x17000    0x17000    com.apple.driver.AppleInputDeviceSupport (2410.2) 77D512B4-8C20-3F85-AAC7-1E369280DCA7 <19 6 5 3 1>
   91    1 0xffffff7f825f8000 0x27000    0x27000    com.apple.driver.AppleMultitouchDriver (2410.5) 843EC1D8-9EF8-3957-A6DE-3BA2C75DA2EF <90 43 18 8 6 5 3 1>
   92    5 0xffffff7f830df000 0xf6000    0xf6000    com.apple.iokit.IOBluetoothFamily (6.0.9f2) B346DC72-6C1D-3D18-AF53-243006DE8F60 <23 18 12 8 7 6 5 3 1>
   93    1 0xffffff7f831ea000 0x1a000    0x1a000    com.apple.driver.IOBluetoothHIDDriver (6.0.9f2) C65C951F-5EA3-3567-888E-9426F9C6C9CE <92 43 6 5 3>
   94    1 0xffffff7f833e7000 0xe000     0xe000     com.apple.driver.AppleHSBluetoothDriver (138.2) 0FB609EB-A6D5-31B5-9191-BBE7E108E0D6 <93 92 43 7 6 5 3 1>
   95    0 0xffffff7f83408000 0xa000     0xa000     com.apple.driver.AppleTopCaseHIDEventDriver (138.2) DEB5AF27-6B55-3330-A457-5A171EE71B53 <94 91 43 7 6 5 3 1>
   96    0 0xffffff7f8133f000 0x8000     0x8000     com.apple.driver.usb.AppleUSBHostCompositeDevice (1.2) 8C1845F2-B482-3839-AFBD-7615B63A966E <23 22 7 6 5 3 1>
   97    0 0xffffff7f81513000 0x8000     0x8000     com.apple.driver.usb.networking (5.0.0) CCD5FEBF-603E-3954-93DC-5286ED1AE7C8 <23 7 6 5 3 1>
   99    2 0xffffff7f8239e000 0xce000    0xce000    com.apple.vecLib.kext (1.2.0) D2378E7F-77C5-33C4-9DFB-44CEDA8978FF <10 7 6 5 3>
  100    4 0xffffff7f8246c000 0x3f000    0x3f000    com.apple.iokit.IOAudioFamily (206.5) FC2441AE-A64B-39A6-8D27-16DA45778ABA <99 6 5 3 1>
  103    0 0xffffff7f8383f000 0xd000     0xd000     com.apple.driver.AppleUSBCardReader (456.200.8) BF35B7EC-BB31-39AA-A238-C248EC1F84B7 <29 28 27 26 23 6 5 3 1>
  106    0 0xffffff7f816bc000 0x35000    0x35000    com.apple.driver.usb.AppleUSBHub (1.2) 6011B60F-66A2-3D6E-B947-D854B7573C14 <23 22 12 6 5 3 1>
  109    2 0xffffff7f834f4000 0xb000     0xb000     com.apple.iokit.IOBluetoothHostControllerTransport (6.0.9f2) 09AC3436-48F6-3003-82D2-371ACDD1E4F8 <92 23 13 12 8 7 6 5 3 1>
  110    1 0xffffff7f83506000 0x20000    0x20000    com.apple.iokit.IOBluetoothHostControllerUSBTransport (6.0.9f2) 045D949C-F523-382B-BF9E-3E76EB36EED0 <109 92 23 13 12 8 7 6 5 3 1>
  111    0 0xffffff7f83526000 0xc000     0xc000     com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport (6.0.9f2) 5A700044-E9EF-3F04-8372-F8802DE5BD4A <110 109 92 23 13 12 8 7 6 5 3>
  112   15 0xffffff7f81466000 0x4b000    0x4b000    com.apple.iokit.IOGraphicsFamily (530.12) 9D1E5FA7-267E-397E-9C91-1751221A05CF <13 8 6 5 3 1>
  113    0 0xffffff7f838ee000 0x5000     0x5000     com.apple.driver.AppleSMCLMU (212) C98DA56E-747A-36CE-9E12-F69D9C921A34 <112 14 6 5 3>
  114    0 0xffffff7f8346a000 0x4000     0x4000     com.apple.driver.AppleOSXWatchdog (1) D4512DAB-736E-3D89-8BFD-1A8DCCA652BD <13 8 7 6 5 3 1>
  118    1 0xffffff7f83546000 0xe000     0xe000     com.apple.driver.AppleSMBusController (1.0.18d1) 94B0E3A1-1A19-34C4-BCD0-DB97AF011A27 <44 13 12 6 5 3>
  119    0 0xffffff7f83557000 0xf000     0xf000     com.apple.driver.AppleMCCSControl (1.5.6) F7C24EF2-BD7F-3074-941B-1AA5485D465C <118 112 14 13 12 8 6 5 3 1>
  120    1 0xffffff7f814be000 0x5000     0x5000     com.apple.iokit.IOSlowAdaptiveClockingFamily (1.0.0) 3B87A06D-D6A2-3DB8-B093-A4B91EFCA4D2 <8 7 6 5 3 1>
  121    0 0xffffff7f834db000 0x2000     0x2000     com.apple.driver.AppleIntelSlowAdaptiveClocking (4.0.0) DBB6E586-748A-39E2-BC59-9748D8E395A2 <120 5 3>
  123    2 0xffffff7f82b47000 0x22000    0x22000    com.apple.iokit.IOSurface (255.1) B153C6D6-2542-3D6F-A21F-B56D9E1349DF <8 7 6 5 3 1>
  124    2 0xffffff7f82b6b000 0xa5000    0xa5000    com.apple.iokit.IOAcceleratorFamily2 (400.27) 5BC3E111-E908-36E8-9AFB-A39BD0D561D5 <123 112 31 18 13 8 7 6 5 3 1>
  125    4 0xffffff7f81824000 0x9000     0x9000     com.apple.AppleGraphicsDeviceControl (3.25.6) 53E6D711-F2EF-35EE-8974-7BDCE4281C83 <112 13 8 7 6 5 3 1>
  126    0 0xffffff7f82c20000 0x195000   0x195000   com.apple.driver.AppleIntelBDWGraphicsFramebuffer (12.0.2) FFF38028-F575-301D-8B12-7713A1A39A02 <125 124 112 18 13 12 8 7 6 5 3 1>
  127    0 0xffffff7f81552000 0xa8000    0xa8000    com.apple.driver.AppleCameraInterface (6.8.0) 2B835CCE-DBF5-3C79-8950-54063C24231C <13 8 7 6 5 3 1>
  128    2 0xffffff7f82779000 0xc000     0xc000     com.apple.iokit.IOHDAFamily (282.10) 917C1366-DF57-3FE5-A81C-D1111AB3DA4E <6 5 3 1>
  129    1 0xffffff7f82788000 0x1d000    0x1d000    com.apple.driver.AppleHDAController (282.10) 41CE33FB-FED7-36D3-A3DF-03B036329B10 <128 112 100 13 8 7 6 5 3 1>
  130    0 0xffffff7f82eb0000 0x16000    0x16000    com.apple.driver.AppleThunderboltIP (3.1.2) 3A00083A-3BA9-3C54-A5B8-35CCD7D29FA5 <68 16 13 6 5 3 1>
  131    0 0xffffff7f81867000 0xd000     0xd000     com.apple.AppleGPUWrangler (3.25.6) 1D2B961F-CE14-3D06-9FD8-AE4B2727B905 <125 112 13 8 7 6 5 3 1>
  132    3 0xffffff7f8184a000 0x10000    0x10000    com.apple.iokit.IONDRVSupport (530) 8039D042-BB38-392F-B074-85B9C7116787 <112 13 8 6 5 3>
  133    1 0xffffff7f8185a000 0x6000     0x6000     com.apple.driver.AppleBacklightExpert (1.1.0) 99E56ED6-ED0B-3836-A06B-65A6DE4F2369 <132 112 14 13 6 5 3>
  134    0 0xffffff7f83726000 0x5000     0x5000     com.apple.driver.AppleBacklight (170.12.11) 16727824-097F-3EC3-8B50-006044F12DAC <133 132 112 13 6 5 3>
  135    0 0xffffff7f83629000 0x5000     0x5000     com.apple.Dont_Steal_Mac_OS_X (7.0.0) E8A46A07-5CA9-3449-AB3C-194D7EDBDEC6 <14 9 8 5 3 1>
  136    0 0xffffff7f83571000 0x12000    0x12000    com.apple.driver.pmtelemetry (1) F5DF1818-B776-319E-9EC2-2CF112FF664B <8 7 6 5 3>
  137    0 0xffffff7f83536000 0xa000     0xa000     com.apple.iokit.IOBluetoothSerialManager (6.0.9f2) 05E1AD9E-E430-3A0F-9A62-07D287E9C7E3 <85 8 6 5 3 1>
  138    0 0xffffff7f83367000 0xd000     0xd000     com.apple.driver.AppleSSE (1.0) 0FE8A579-292F-3A7A-9EBF-37957176CB07 <24 20 19 8 6 5 3 1>
  139    0 0xffffff7f8327e000 0x6000     0x6000     com.apple.iokit.IOUserEthernet (1.0.1) B859588F-BDD5-34CF-848E-E57F9365357B <16 7 6 5 3 1>
  140    0 0xffffff7f830c9000 0x9000     0x9000     com.apple.driver.AppleHV (1) 9E7E8649-E346-3C55-A80B-A3DBA88EF25F <8 7 6 5 3 1>
  141    0 0xffffff7f82f87000 0x9b000    0x9b000    com.apple.driver.AppleIntelBDWGraphics (12.0.2) 1BF3C872-B8B9-3F5F-912F-345E51BF4C5D <124 123 112 13 8 7 6 5 3 1>
  143    2 0xffffff7f82521000 0x7000     0x7000     com.apple.iokit.IOEthernetAVBController (1.1.0) 3390BB2D-8D49-3548-A842-6EBC8AD543B7 <16 6 5 3 1>
  144    1 0xffffff7f82528000 0x9b000    0x9b000    com.apple.plugin.IOgPTPPlugin (700.7) C827CEDD-5EA0-381E-BA79-584BA3AD4F24 <143 43 17 16 10 7 6 5 3 1>
  145    0 0xffffff7f825d6000 0x10000    0x10000    com.apple.iokit.IOAVBFamily (710.1) 991BDC83-FD82-39B2-B58E-81D0BD83714F <144 143 17 16 7 6 5 3 1>
  146    0 0xffffff7f814ef000 0x5000     0x5000     com.techsmith.TACC (1.0.2) 4C96D504-16DB-3A11-84E8-AC971A4632AC <6 5 3>
  147    1 0xffffff7f827ab000 0x13000    0x13000    com.apple.kext.OSvKernDSPLib (527) C39D546B-2D04-3E1E-A96F-9A478137270E <6 5>
  148    1 0xffffff7f827be000 0x142000   0x142000   com.apple.driver.DspFuncLib (282.10) 64DB847E-EC8E-3784-A4FE-E3EE39D69FC4 <147 100 99 51 7 6 5 3 1>
  149    0 0xffffff7f8290b000 0xb7000    0xb7000    com.apple.driver.AppleHDA (282.10) 9BB2B0F6-EDD8-397A-9EBB-05508910C3EC <148 132 129 128 112 100 7 6 5 3 1>
  150    0 0xffffff7f8182f000 0x3000     0x3000     com.apple.AGDCPluginDisplayMetrics (3.25.6) 9DCEDC83-70CF-31AF-AF8C-0F2573D5FE62 <125 8 7 6 5 3 1>
  152    1 0xffffff7f81833000 0x3000     0x3000     com.apple.driver.AppleGraphicsControl (3.25.6) 24510B87-FDA5-3AAE-97B5-601D6BAD73B9 <8 6 5 3 1>
  153    0 0xffffff7f81836000 0x12000    0x12000    com.apple.driver.AppleGraphicsDevicePolicy (3.25.6) BC4D1C7C-7B84-3638-81B7-6400B691A5C1 <152 125 112 13 12 8 7 6 5 3 1>
  154    0 0xffffff7f83384000 0x5000     0x5000     com.apple.driver.AppleUpstreamUserClient (3.6.5) 01FEB078-055C-3879-94C6-C2A9C7CFF2BF <112 13 12 8 6 5 3 1>
  155    0 0xffffff7f8142a000 0x3000     0x3000     com.apple.driver.eficheck (1) 3FC32988-257D-3170-8C6E-90D8927D1862 <50 13 5 3 1>
  156    1 0xffffff7f834cb000 0x5000     0x5000     com.apple.kext.triggers (1.0) E563E9F4-A6ED-3A9F-9A6A-6D0D773B4C63 <8 7 6 5 3 1>
  157    0 0xffffff7f834d0000 0x9000     0x9000     com.apple.filesystems.autofs (3.0) CC46463A-A74D-3535-84AB-CAD5247AB0B0 <156 8 7 6 5 3 2 1>
  158    0 0xffffff7f8372e000 0x5000     0x5000     com.apple.driver.AudioAUUC (1.70) 7A6398A8-7F7F-346F-9586-F5F902C26290 <112 100 13 12 8 6 5 3 1>
  159    0 0xffffff7f814f8000 0x17000    0x17000    com.apple.fileutil (1) DBC84499-EDB0-3120-A43C-C4F016D68A30 <6 5 3 2 1>

Best Answer

There's a difference between the two as they are two completely different things. It would not make sense to compare them or expect that they should be equal.

The Size column in your kextstat output shows much memory the kernel extension itself takes up in memory. This is the amount of the memory that the code/data in the kernel extension itself takes up (i.e. comparable to the binary file size of the kernel extension). It doesn't have anything to do with how much memory the kernel extension has used. Kernel extensions can dynamically allocate memory while running, and it doesn't show up in the Size column here, as it is a different thing.

The kernel_task memory usage shown is htop shows the actual memory usage of the kernel - this includes dynamically allocated memory. It can include memory used for the kernel itself, kernel extensions or memory allocated by the kernel on behalf of applications.

UPDATE: You have updated your question to ask a completely different question - namely "How to debug what threads take the most of the memory?".

This seems to indicate to me that this is a X/Y-question - you probably have some root issue you want to solve, and somehow you've come down a path where it makes sense for you to ask this question. However, the question doesn't really make much sense in technical terms, so it is difficult to actually help you without details on the actual problem you're trying to solve.

Technically, you cannot in general separate memory usage for each thread in a task like you want to do here. The very definition of threads (in this case, and almost always in other cases) is that they share memory with other threads. Therefore several threads inside a task could be using the same memory - and one thread can allocate memory that is used by a second thread that is eventually deallocated by a third thread. There exists a special class of memory named "thread local storage" which is really separate for each thread, but this construct is not commonly used in the macOS kernel (or in kernels in general).

Obviously you could instrument the kernel to log each allocation of memory and noting which thread did the allocation - but it wouldn't allow you to directly conclude that any "bug" is actually in that thread or anything like that.

By reading your question and various comments, you original problem sounds like you think your system is using too much memory, and you think a kernel extension is the culprit, but you do not know which one. These assumptions might be wrong (also on your part, as it is very common for non-technical people to have wrong assumptions on how memory allocation in computers actually work today).

In any case, I think the tool you might be looking for is simply zprint. Start Terminal.app and run:

sudo zprint -s -t 

This will print the total size of allocations created in each zone sorted by the sum.

This won't tell you which thread uses the most memory (obviously), but it is probably the values you're actually looking for.