3 ms·
Go's garbage collector is implemented in Go.
by 4ad 10y ago
Go's garbage collector is implemented in Go.
- Someone 10y agoI can't find it in the documentation, but I would think that must be implemented in ProtoGo, where ProtoGo is a Go-like language that doesn't use Go's garbage collector or a library that does (Enforcing not using anything that uses the garbage collector may be left to the programmer) That is necessary even with a concurrent garbage collector because a garbage collector that allocates in its own heap may hang itself (propaganda allocates; gc triggered; gc allocates; gc triggered to satisfy the allocation; new gc triggered; etc.) . Or do Go's developers accept this risk and live with it?
- 4ad 10y ago> Enforcing not using anything that uses the garbage collector may be left to the programmer It's left to the compiler actually. Programmers can't be trusted. The runtime does not implicitly generate garbage (like arbitrary Go code). It is compiled with a mode that fails compilation if something can't be stack-allocated. When heap allocation is necessary, it is requested manually. However, the memory returned is garbage collected, as usual, there is no free.
- pjmlp 10y agoBesides 4ad reply, here you can see how Oberon has its GC implemented in Oberon, as another example of a bootstrapped GC enabled systems programming language. http://people.inf.ethz.ch/wirth/ProjectOberon/Sources/Kernel.Mod.txt http://people.inf.ethz.ch/wirth/ProjectOberon/Sources/Kernel...