< Back to all clusters
[TECHNOLOGY] · France · 2 sources

started · updated

TinyGo implements CGo improvements and memory management strategies

TinyGo is implementing technical improvements regarding CGo support and memory management strategies. In terms of CGo, the compiler can now inline C code when it is placed within the import "C" block, a feature supported since version 0.21.0. This allows for significantly reduced overhead compared to standard Go, as TinyGo performs regular calls rather than the complex stack-switching and convention conversions required by the main Go implementation.

Regarding memory management, TinyGo utilizes several garbage collection (GC) strategies depending on the architecture and use case. For bare-metal systems like microcontrollers, it primarily employs a conservative mark/sweep garbage collector. Other methods include a bump-pointer heap implementation for initialization-only allocations and a heap implementation designed for working with external C malloc memory. The memory layout on microcontrollers typically places the call stack at the bottom to provide hardware-based stack overflow checking, followed by data and BSS sections, with the heap occupying the remaining space.

Entities

Go · TinyGo

Sources

7 days ago
7 days ago