Skip to main content

Motoko update May 17, 2023

by Kento Sugama


Hey Motoko developers! 👋

Welcome back to the latest Motoko update post! If you happened to miss our previous update, you can catch up here. We discussed a new Bitcoin hackathon for ICP and the VSCode candid features.

Today, we’re excited to discuss a beta test for the new incremental GC! If you want to test out the full usage of the Motoko heap then keep reading!


Incremental Garage Collector: Beta Release!

A new, powerful garbage collector, the incremental GC, has been released for beta-testing with version 0.9.0 of Motoko! The biggest impact of the incremental GC is that it enables heap usage in Motoko up to the full 4GB limit. While the existing GCs are unable to collect the whole heap due to the instruction limit per message, the new GC distributes its work across multiple messages when needed. Using evacuation-compaction based on forwarding pointers, the GC guarantees limited short pauses in all phases and is comparable to the most modern and advanced GCs used in other languages (e.g. Java). The GC’s scalability would also be a key enabler when moving Motoko to a 64-bit heap space in the future. Based on our GC benchmark, the incremental GC allows allocating up to 3x more heap space while consuming around 3-16% less cycles on average compared to the other GCs available in Motoko. For the moment, the incremental GC is only intended for beta testing and can be explicitly activated by the —incremental-gc compiler flag. You can enable the feature in dfx.json like so:

“canisters”: {
“my_dapp”: {
“main”: “src/”,
“type”: “motoko”,
“args” : “--incremental-gc”

Please let us know of any feedback and special shoutout to @luc-blaeser for leading and building out this large and complex feature! More information on the incremental GC can be found here.

'Til next time!

Keep building, and stay tuned for more updates! – DFINITY Languages team