When does the stack really overflow?

后端 未结 6 1561
别跟我提以往
别跟我提以往 2020-12-17 05:35

Is infinite recursion the only case or can it happen for other reasons? Doesn\'t the stack size grow as needed same as heap?

Sorry if this question has been asked be

6条回答
  •  情话喂你
    2020-12-17 05:40

    If your program exceeds its alloted stack space without any infinite recursion going on, then you're doing something wrong.

    Though it can happen if you leave off some asterisks and try to pass some huge buffers by value.

    The memory allocated for the stack does generally grow as needed within reasonable boundaries - I'm not sure what the upper limit is on various systems.

提交回复
热议问题