I was going through some Real time OS specifications and I read that In RTOS we usually don't prefer to use malloc. The reason for this was given as: for performance issue we should not use malloc as it is time consuming to allocate memory through malloc and also overhead to keep track of allocated memory is higher.
Now In real time systems, time constraint is there with all the processes, we generally don't use malloc. I got curious and started researching a bit like how memory is actually allocated at run time in RTOS and I found Memory pools. Now It was written that memory pools actually means as fixed size block allocation.Now advantages of Memory pools is that It doesn't suffers from fragmentation. How is it possible? Suppose that we have 3 pools of 4 bytes and the application requires 10 bytes, so in this case memory pools will suffer from internal fragmentation.
How do the memory pools work and how the memory is allocated? Do the applications get the pools at compile time like a particular application will get 3 pools from pool size of 4bytes? What if they require memory that cannot fit in the pools. Are many memory pools of different sizes present in such system? Please explain it to me.