Are there any languages other than C and C++ that can be used explicitly without dynamic memory allocation (i.e. heap) features. In some mission critical embedded systems, use of the heap is prohibited to eliminate memory leak problems for software that may run continuously for many years. Some special purpose compilers also explicitly disable new
and malloc
to enforce this practice.
I've looked at some of the functional languages, namely Timber and Erlang for their embedded emphasis, but both seem to use heaps with a garbage collector. OCaml and Haskell also use garbage collectors despite static typing, and obviously Python, Ruby, and other dynamically typed languages rely heavily on garbage collection and heap space.
When it comes to C, memory is allocated using the functions malloc(), calloc() and realloc() and de-allocated using free(). However in objected oriented languages like C++,C# and Java, memory is dynamically allocated using the new and deallocated using delete keywords (operators) in case of C++.
C++ allows us to allocate the memory of a variable or an array in run time. This is known as dynamic memory allocation. In other programming languages such as Java and Python, the compiler automatically manages the memories allocated to variables.
Implementations in C and C++ were fastest and used the least memory. Programs in these languages generally contained more lines of code.
Computer programs need to allocate memory to store data values and data structures. Memory is also used to store the program itself and the run-time system needed to support it. If a program allocates memory and never frees it, and that program runs for a sufficiently long time, eventually it will run out of memory.
You could have a look at ADA. I've been using ADA83 on embedded platforms a few years ago. It didn't require dynamic allocation at all, and it is as high-level as C is (it's even better than C, in my own opinion). The problem, of course, is to get an ADA compiler for your platform. Maybe GNAT would work for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With