Frequent "cannot allocate memory" errors during HTTP requests in scripts
I'm on an M2 air with Sonoma 14.4.1. I frequently see errors mentioning "cannot allocate memory" while using tools that make HTTP requests from the command line. I first experienced it with my code and thought I had a memory leak, but I was never able to identify and fix one, then I started noticing it with major CLI programs. Concrete example:
> gh status
failed to search: could not search for assignments: Post "https://api.github.com/graphql": dial tcp 140.82.116.5:443: connect: cannot allocate memory
The error has occurred with gh, gcloud, as well as my own node and python scripts. It seems to be a lower level problem with the OS networking layer than something in these tools. There is no discernible pattern to when they occur. They persist after restarts. Sometimes repeating the same command works. If a command makes many HTTP requests, however, it almost always eventually emits a memory error, though at unpredictable points.
Is this just an OS error and I have to wait for an update? Is there any many to free up memory for network requests? Activity Monitor shows my memory nowhere near maxed out when the errors happened. I've also tried closing all other running applications but the error still occurs. It seems to have nothing to do with the actual resources available.
[Edited by Moderator]
MacBook Air (M2, 2022)