Alternative memory allocators

Currently RTEMS only provides a single dynamic memory allocator which is the first fit memory allocator. This allocator’s only method of garbage collection is performed each time a block is returned to the heap by merging neighboring blocks. As mentioned by the original ticket this type of allocator in a real-world dynamic application it is subject to:

  • unpredictable allocation times (linear search through free blocks).
  • memory fragmentation.

Some implementations of allocators was provided in the ticket above:

  • TLSF
  • jemalloc
  • kernel malloc based on UMA used in free bsd

After doing some research the only one that should be able to work in RTEMS is TLSF since others need virtual memory. What I was thinking of is making the allocator modular like FreeRTOS where there are multiple implementations of the heap and the user can either choose one of them via configurations or provide an implementation of his own. I don’t know if this is possible in RTEMS since it is more complicated than FreeRTOS especially considering that RTEMS provides a networking stack, SMP and more variations of Boards.

These are the tickets related to this topic:
rtems/rtos/rtems#3757
rtems/rtos/rtems#3582

1 Like

Add mimalloc to the list.