Is it safe to declare a variable inside an infinite loop ?

for {
    a := 0
    a += 1
}

Won't this cause memory allocation in every iteration ?

As the declared variables will be allocated memory in the stack and not 
heap memory, so garbage collector can't clear the allocated memory, and 
eventually process will be terminated, isn't it?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7f61ab5e-f0c3-40e1-b903-c4aec087f7a3n%40googlegroups.com.

Reply via email to