Sobes.tech
Junior — Middle

At what point does a created goroutine reserve memory during execution?

sobes.tech AI

Answer from AI

In Go (Golang), each created goroutine reserves memory on a stack, which is initially small (usually around 2 KB). This stack is allocated during execution and can dynamically expand if necessary. The memory for the goroutine's stack is allocated from the heap, managed by the Go runtime. This approach allows efficient memory usage and the ability to run thousands of goroutines without significant resource costs.