Memory allocation is an optional feature of ChibiOS/RT. The kernel itself never allocates nor frees objects at runtime but memory management services are offered to the application if required.
|This switch enables the core allocator module, this module is required by all the other memory management modules.|
|Size of the memory block to use as memory core area. If set to zero then the whole available RAM is used.|
|This switch enables the heap allocator module.|
|This switch enables the memory pool allocator module.|
|This switch enables the dynamic threading services.|
This module is responsible for allocating memory blocks from the system RAM, allocated blocks cannot be returned. The implementation is quite simple:
Note that the Core Allocator module expects two global symbols to be defined:
__heap_base__is the base address of the unused RAM area.
__heap_end__is the end address of the unused RAM area.
The symbols are usually exported by the linker thanks to a specially crafted scatter file. The core allocator allocates blocks starting from the base address up to the end address. The allocated blocks are guaranteed to be aligned to the most restrictive data type for the current architecture. Requesting more memory than the remaining size results in an error.
|Allocates a memory block of the specified size.|
|Allocates a memory block of the specified size (I-Class variant).|
|Returns the remaining memory size.|
All the allocators can be used together but some are best suited in specific scenarios, this is a brief comparison:
|Allocator||Can Free||Constant Time||Variable Size||From ISR||Thread Safe|
|Memory Pool Allocator||yes||yes||no||yes||yes|
|C Library Allocator||yes||no||yes||no||no|
The selection of the appropriate allocator depends on requirements of your application, there is not an universal best solution.