Malloc Embedded Systems

I work with an embedded system. The application runs on the AT91SAMxxxx and cortex m3 lpc17xxx. I am studying dynamic memory allocation, as this will dramatically change the face of the application (and give me more power).

I think my only real route is to allocate a memory area for the heap and create an individual malloc that best suits (pun intended) my goal.

By looking at various memory allocation algorithms, you cannot attack Doug Lea malloc. I suppose this was used in embedded systems, such as mine, where there is no OS and no adapted versions, for example, the sbrk () function was provided for this. I am trying to find good examples of this achievement in order to try to prove the concept before I move on to writing my own.

Can dlmalloc be used on a system like mine?

If so, can someone point me to the appropriate resource? (did not find much that help me)

Is it better to go and write your own malloc that fits my needs?

And I apologize that most of my research so far has been to develop malloc not using doug, which is another task. Guess what I'm trying to find out is exploring this route deeper for nothing.

Edit:

moral of the story: looking at dlmalloc in my case is pointless.

+6
source share
1 answer

For your situation, your own implementation of malloc or dlmalloc definitely possible, but not recommended.

At very low levels of embedded systems, bare metal MCU, etc., using malloc is pointless.

You will run your application and only your application, you know how much memory you have and can use, and you can fully adapt your program to meet such needs. With malloc you save memory, but that is pointless. If your program with the highest memory does not exceed the amount of memory available on the device, and your program runs only one, there is no reason to use malloc, and there is no reason to leave unused memory.

tl; dr Perhaps, but extremely pointless.

+5
source

All Articles