Skip to content
Axel Roest edited this page Nov 16, 2020 · 3 revisions

There is a nice blog post explaining the intricate details of the memory space necessary for swift for Arduino:

Where do all my bytes go?

Excerpt

Our internal Swift for Arduino libraries (AVR) contain functions adding up to 450 bytes. But they also have a fixed overhead; ISRs and constructors, that are always present in every program, 1636, over a quarter of the whole hex file size, that handle interrupts and setup. In our particular case, they are not used by our program so they represent space that could be harvested in an advanced build. Finally, gcc template code, start vectors, libgcc functions and libc functions, including an optimised vfprintf amount to another 3824 bytes, well over half the program size. Some of this, like the 104 bytes of interrupt/reset vectors, are unavoidable, even in an assembly language hand written program. Most of the rest of it should be seen as the typical costs of writing in a high level language, instead of hand written assembly. And would be similar even if we were using C or C++ libraries, indeed the same functions and prologue/epilogue would probably be present in about the same size.

The takeaway is that swift for arduino is remarkably efficient. Creating a main program of 112 bytes, including library functions amounting to only 454 bytes and with a fixed cost of 1606 bytes added to all programs for ISRs/constructors to give a fully featured platform (some of which might be able to be trimmed for super specialised developers needs).