Setting stack size

@larse, there is no way to set the stack size except for new FreeRTOS threads. Calling System.freeMemory() show he available space on the Heap but does not indicate how fragmented it is. Often, memory issues are due to using functions that dynamically allocate and release memory on the Heap, creating fragmentation. This includes some Standard Library functions (eg. <vector>) and more commonly the Arduino String commands. The solution to the latter is to use c-string (char arrays) functions.

If you can describe problem more specifically, we may be able to help more.