Wifi lost when stack grows too large?

I don’t know how to measure the free memory on the stack but we have an Async library that wraps functions upon functions and it seems that if I wrap too many functions in a row, we lose connection to Wifi. Is there any reason to think there is a relationship between these two things, the size of the stack and Wifi dropping? Is there anyways to profile this?

Thanks!

I’d say system calls (including WiFi stuff) will also need some stack space to be call the required functions.
But usually if your device runs out of stack you’ll see an SOS panic and not just loss of WiFi connection.

Or do you rather mean heap instead of stack?
If it’s the heap, then the reason for the WiFi faults will come from the fact that the system also uses dynamic memory allocation for several tasks and if there is no free memory (or rather one single big enough chunk for the respective task) to perform these, the function just fails, but since it’s neatly programmed, fails gracefully and doesn’t cause an SOS panic.

I was trying to figure out how to profile this and I found this just now

It appears from this older thread that if the stack and the heap borders get too close together you get the SOS you are talking about. However, I wonder if the stack gets too large if this would still in some way impact the Wifi’s ability to connect thereby influencing the heap? The only place we are specially using the heap is unrelated to this code and we haven’t had an issues there. This seems directly related to the depth of the number of wrapped lambda’s I create.

Do you know of a way to measure the stack or HEAP and log in? I could take a look but not sure where to begin to get those numbers.