How come Go doesn't have stackoverflows

后端 未结 5 2073
野的像风
野的像风 2021-02-01 19:51

I read in this presentation http://golang.org/doc/ExpressivenessOfGo.pdf page 42:

Safe

- no stack overflows

Ho

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-01 20:33

    it uses a segmented stack. Which basically means it uses a linked list instead of a fixed size array as it's stack. When it runs out of space it makes the stack a little bigger.

    edit:

    Here is some more information: http://golang.org/doc/go_faq.html#goroutines

    The reason this is so great is not because it'll never overflow (that's a nice side-effect), it's that you can create threads with a really small memory footprint, meaning you can have lots of them.

提交回复
热议问题