Why is my Wi-Fi Process eating >2GB memory
Solution 1:
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.