This seems like a great tutorial for both Ada and embedded systems in general. I'm definitely going to have to check this out more. Can someone speak, at a high-level, on how Ada manages memory? I'm gonna read the docs, but if anyone has a good explanation here, that would be appreciated! In general, I'm interested in learning more about embedded languages that are not C/C++ or Rust. To give some context, my dream em…
It often isn’t necessary to explicitly use pointers to dynamically allocated memory. For example, Ada lets you return an array of unknown size by value from a function. These unconstrained objects are stored on what is called a “secondary stack”, which is basically a special allocation pool for holding these objects managed by the language runtime.
When you do use pointers, the compiler is very strict to try and avoid dangling pointers. You can also create custom pointer types and assign them to memory pools, so dynamic allocations of that pointer type get made in the pool (and not in the normal heap).
You can also use manual memory management (using the `new` keyword and the `Unchecked_Deallocation` function similar to malloc() and free()).
There is also a finalizer class you can inherit from that adds a destructor to record types, so you can use RAII, too.