The answer to this question depends on the context. For example, when you write for the kernel of the operating system, the stack can be quite limited, and allocating more than a thousand bytes on the stack can cause a problem.
In modern consumer systems, the space available for the stack is usually quite large. One of the problematic systems was that the address space was limited, and as soon as the address was assigned to the stack, it could not grow beyond the next object in the address space in the direction of the stack growth, regardless of the availability of physical memory or virtual memory elsewhere in the address space . This is less of a problem with today's address spaces.
Typically, megabytes of space can be allocated on the stack, and doing so cheaply and easily. However, if many subprograms that allocate large amounts of space are called, or one or more subprograms that allocate large amounts of space are called recursively, then problems can arise because too much space is used, resorting to a certain limit (for example, the address space or physical memory).
Of course, work in the limit of physical memory will not be reduced by allocating space from the heap. Thus, only the question of using address space for the stack is relevant to the question of whether to use the stack or the heap.
A simple test of whether this is a problem is to insert a large number of stacks into the main space. If you use extra stack space and your application is still running under load, which usually uses large amounts of stack space, then when you delete this artificial reservation in main , you will have a lot of difference.
It would be best to calculate your maximum program that you can use and compare it with the stack space available on the system. But this is very rare with today's software.
If you use stack space restrictions, your linker or your operating system may have options to make them available.