risks of usage on mac/linux/windows c.f. standard go #5223
|
If the tinygo application compiles, is there any risks associated with building for windows/macos/linux compared to standard go? Is the tinygo garbage collector as good as the standard go garbage collector at preventing memory leaks? Notwithstanding that it hasn't been tested as thoroughly and isn't as performant? For example can it detect and free memory that cyclically references each other - the standard go garbage collector can do that. |
Replies: 1 comment
|
On cycles: yes, those get collected. On desktop targets current TinyGo uses the Boehm (bdwgc) collector by default: The real difference is that both are conservative. Any word in memory that happens to look like a pointer into the heap keeps that block alive. In practice that means occasional over-retention, i.e. somewhat higher memory use. It is not a leak that grows without bound, but large heaps full of pointer-like integers (hashes, IDs) can make it noticeable. Go's collector is precise and concurrent, and its pause times and throughput are better under heavy allocation. Check The other production risks are not the GC:
If you aren't after small binaries or WASM, plain If this solves it, please mark it as the answer so others with the same problem can find it. |
On cycles: yes, those get collected. On desktop targets current TinyGo uses the Boehm (bdwgc) collector by default:
GOOS=darwin,linuxandwindowsall setGC = "boehm"in compileopts/target.go. Older releases and other targets fall back to TinyGo's ownconservativecollector (config.go L166-174). Both are mark-and-sweep. They trace from the roots, so unreachable cycles are freed just like with gc. Reference cycles are only a problem for reference-counting collectors, which neither of these is.The real difference is that both are conservative. Any word in memory that happens to look like a pointer into the heap keeps that block alive. In practice that means occasional over-retention, i.e.…