Possibly the worst sin of calling malloc is that it might take a very long time to complete. You can find a lot of advice that you should avoid dynamic memory allocation on embedded systems. That’s pretty sound guidance. However,
Why is malloc() harmful in embedded systems? – Quora
Using malloc() or any other dynamic memory allocation is harmful in embedded systemsbecause: The memory is limited in embedded systems. (it is important that you do not suddenly find yourself out of memory). Fragmentation – embedded systems can run for