Mojave Wi-Fi app using 2GB of memory [duplicate]

Activity Monitor

Why is the Wi-Fi process taking so much memory?

EDIT: Apologies, I should have clarified my question. I'm a web developer that spends most of his time developing apps locally. Not interacting with third party apis or database interactions. Possibly it might be my app bundler Webpack serving updated changes constantly to my local server?

Specs

  • MacBook Pro (Retina, 13-inch, Mid 2014)
  • 2.8 GHz Intel Core i5
  • 8 GB 1600 MHz DDR3
  • Mojave 10.14.2
cwd
/
txt
/System/Library/CoreServices/WiFiAgent.app/Contents/MacOS/WiFiAgent
txt
/Library/Preferences/Logging/.plist-cache.ptlzg4rP
txt
/private/var/db/timezone/tz/2018g.1.0/icutz/icutz44l.dat
txt
/System/Library/Caches/com.apple.IntlDataCache.le.kbdx
txt
/usr/share/icu/icudt62l.dat
txt
/System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/SystemAppearance.car
txt
/System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/VibrantLightAppearance.car
txt
/System/Library/Keyboard Layouts/AppleKeyboardLayouts.bundle/Contents/Resources/AppleKeyboardLayouts-L.dat
txt
/Library/MessageTracer/SubmitDiagInfo.default.domains.searchtree
txt
/private/var/db/mds/messages/502/se_SecurityMessages
txt
/System/Library/Frameworks/SecurityInterface.framework/Versions/A/Resources/[email protected]
txt
/System/Library/Frameworks/SecurityInterface.framework/Versions/A/Resources/CertLargeStd.png
txt
/System/Library/Fonts/SFNSText.ttf
txt
/System/Library/Frameworks/AppKit.framework/Versions/C/Resources/Assets.car
txt
/System/Library/PrivateFrameworks/CoreWLANKit.framework/Versions/A/Resources/Assets.car
txt
/usr/lib/libobjc-trampolines.dylib
txt
/System/Library/Frameworks/SecurityInterface.framework/Versions/A/Resources/Assets.car
txt
/System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/DarkAquaAppearance.car
txt
/System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/DarkAppearance.car
txt
/System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/Assets.car
txt
/private/var/folders/d5/y540nrk96fnckhlwyy_9yxsw0000gp/C/com.apple.wifi.WiFiAgent/com.apple.metal/Intel Iris Graphics/functions.data
txt
/private/var/folders/d5/y540nrk96fnckhlwyy_9yxsw0000gp/C/com.apple.wifi.WiFiAgent/com.apple.metal/3902/libraries.data
txt
/usr/lib/dyld
0
/dev/null
1
/dev/null
2
/dev/null
3
/dev/io8log
4
/dev/io8logtemp
5
*:*
6
/Library/MessageTracer/SubmitDiagInfo.default.domains.searchtree
7
->0x65d3d29751cfa425
8
/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib.metallib
9
/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_filters.metallib
10
/private/var/folders/d5/y540nrk96fnckhlwyy_9yxsw0000gp/C/com.apple.wifi.WiFiAgent/com.apple.metal/3902/libraries.maps
11
/private/var/folders/d5/y540nrk96fnckhlwyy_9yxsw0000gp/C/com.apple.wifi.WiFiAgent/com.apple.metal/3902/libraries.data
12
/private/var/folders/d5/y540nrk96fnckhlwyy_9yxsw0000gp/C/com.apple.wifi.WiFiAgent/com.apple.metal/Intel Iris Graphics/functions.maps
13
/private/var/folders/d5/y540nrk96fnckhlwyy_9yxsw0000gp/C/com.apple.wifi.WiFiAgent/com.apple.metal/Intel Iris Graphics/functions.data

Since I develop, I would prefer to have more memory for simulators, compilers and running dev infrastructure and tools. How can I diagnose why memory is being allocated for wireless networking?


TL;DR - Your Wi-Fi program uses memory when you have network connections. It starts with little allocation and when you run other programs, Wi-Fi uses memory to do that work. Log out to free that memory if you don't want to quit programs or thr don’t release their connections to your liking.

  • Why is my Wi-Fi process using 3GB of memory?

As a developer (or just someone curious about memory allocation / virtual and resident/swap), it's pretty easy to dump the heap and virtual memory map for any process to inspect your current memory allocations.

sudo heap Wi-Fi

Except there's a wrinkle with Wi-Fi so you'll want to pass the process number the actual name of the binary, instead of the whole friendly name. (If you get close - heap knows to prompt you with a list of potential matching processes sudo heap Wi

sudo heap WiFiAgent
sudo mmap WiFiAgent

Now, the larger idea is Apple has re-architected the networking stack. On older OS, kernel just absorbed all the memory needed for networking, but now there are 4 programs (2 pairs) that run in user space and root space and the only reason they use Mach ports and memory is to serve and buffer network connections. If you have less connections open, the usage is small. In practice, I've never seen this cause issues since when you log out and back in (especially if you have no apps start at log in), the allocation of this set of programs is very lean and small.

They only grow when you run programs - so you'd need to look at the programs you run to reduce the load they put on networking. Browsers with lots of tabs open, "apps" that are really electron frameworks and node apps can be chatty on the network side or allocate a lot of resources when a more clean native app might use less system resources.

Wi search in activity monitor