3 ms·
I believe you can turn off the garbage collector in go.
by d0lph 11y ago
I believe you can turn off the garbage collector in go.
- AndyKelley 11y agoUh. Citation needed.
- bitdivision 11y agoYou can set the environment variable GOGC=off [1] There doesn't actually seem to be a way to explicitly free memory though so I doubt this is actually used. [1]: https://golang.org/pkg/runtime/ https://golang.org/pkg/runtime/
- Zancarius 11y agoIt's only intended for debugging purposes, near as I can tell (and I'm not sure why anyone would want to do it in the first place beyond debugging): https://github.com/golang/go/issues/13761#issuecomment-167721220 https://github.com/golang/go/issues/13761#issuecomment-16772...
- deleted 11y ago[deleted]
- d0lph 11y agoI stand corrected, there doesn't seem to be a way to manually allocate and de-allocate memory. Looks like there is a switch to turn off GC, but it's intended for debugging.
- bitdivision 11y agoYou might be right, but the language certainly isn't designed around not having garbage collection.
- hnbroseph 11y agoi'm not particularly experienced with go, but it does work directly with pointers iirc. all it lacks is an explicit memory free function, i think. is there more to it?