Heaps in real time currently exist, but in general, memory heap operations (dynamic allocations and deallocations) are a canonical example of a non-deterministic operation . This means that the execution time varies and does not even have a very good binding.
The problem is that you usually need contiguous blocks of memory merged into one block when they happen. If this is not done, in the end you will only have a bunch of tiny blocks, and a large selection may fail, although in fact there is really enough memory for it. For any given call, a merger may or may not occur, and the amount to be made may differ. It all depends on the distribution / release scheme your system has recently performed, which you do not plan at all. Therefore, we call it "non-deterministic."
If you do not like this behavior, there are two possibilities:
- Switch to real-time heap usage. Your OS probably does not have a built-in device, so you have to buy or download it and use it for all operations with your memory. The one I used in the past is TLSF .
- Do not dynamically allocate / free memory in your main loop (IOW: not after initialization). This is how we, real-time programmers, have learned to program for centuries.
source share