Well, I used runtime runtime.MemStats StackInuse.
I don't have much knowledge about compiler optimization.
But to make it clear for myself:
considering these 2 functions:
//go:noinline
func A() {
var h int
for i := 0; i < 1e5; i++ {
h = i
_ = h
fmt.Printf("%+v\n", &h)
}
}
//go:noinline
func B() {
for i := 0; i < 1e5; i++ {
h := i
_ = h
fmt.Printf("%+v\n", &h)
}
}
The address of h in B is changing in each iteration although it's not causing stack to grow.
If you point me to the documentation for this specific case, I would appreciate it.
Regards,