Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Languages suited for development without dynamic memory allocation

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.

  • Do any high-level languages support this requirement of not dynamically allocating memory?
  • Is this even possible for compilers of functional statically typed languages to do so given their language semantics?
like image 525
kgraney Avatar asked Jun 06 '13 15:06

kgraney


People also ask

What languages use dynamic memory allocation?

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++.

Does C++ support dynamic memory allocation?

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.

Which programming language uses least memory?

Implementations in C and C++ were fastest and used the least memory. Programs in these languages generally contained more lines of code.

Is memory allocation important in programming languages?

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.


1 Answers

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.

like image 163
Alexandre Vinçon Avatar answered Sep 27 '22 23:09

Alexandre Vinçon