The stack is used to store local variables, pass parameters in function calls, and store return addresses. The stream stack has a fixed size, which is determined when the stream is created. This is the meaning that you also have in mind.
The stack size is determined when the stream is created, since it must occupy the adjacent address space. This means that the entire address space for the thread stack must be reserved at the point where the thread was created.
If the stack is too small, it may overflow. This error condition, known as the stack overflow, from which this website got its name. When you call a function, the following or the following happens:
- Parameters are pushed onto the stack.
- The return address is pushed onto the stack.
- A stack stack is created that contains the space for local function variables.
All this takes up space from the stack. When a function in turn calls another function, more stack space is consumed. As the call stack goes deeper, more stack space is required.
The consequence of this is that setting too large a stack is that you can run out of stack and overflow it. This is the final condition from which it is impossible to recover. Of course, 32 bytes (rounded to one page, which is 4096 bytes) is too small for almost all streams.
If you have a program with a large number of threads, and you know that a thread does not need to reserve 1 MB of stack size, then there may be advantages to using a smaller stack size. This avoids running out of available process address space.
On the other hand, you may have a single-thread program that has deep call stacks that consume a lot of stack space. In this case, you can reserve more than the default value of 1 MB.
However, if you have no good reason for doing this, it is best to stick to the default stack size.