3 ms·
You can still stack allocate things in Go. And use closures when you need nested scopes. This lets you take garbage off the heap, and avoid GC all together if
by jaimeyap 12y ago
You can still stack allocate things in Go. And use closures when you need nested scopes.
This lets you take garbage off the heap, and avoid GC all together if you want to.
I believe Go does escape analysis so you can still shuffle around pointers to local structs within a stack frame without causing a heap allocation.
edit: That being said you can't really implement something like refcounting for structs you pass around by pointer outside the local stack frame without the compiler emitting an allocation on the heap. To totally avoid using the GC you'll need to do a lot of copying. And there aren't destructors.