This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

using malloc() in ARM7

I haven't had the need in a while to use malloc() in my applications. I was using it to test something, but I get linker errors 'No space in execution regions...(.data)'. I get this even when I do a malloc(1).

The startup file has a heap size of 0x2000, so I think I'm missing some other setting. I wanted to use malloc to create and free 1600 bytes over and over, so as not to create an array (which actually compiles and runs by the way - so I'm not out of RAM space anyway). So, what other settings do I need to look at?

Thanks,

Sutton

  • The actual malloc() call will not produce any error.

    So I have to assume that you are talking about a linker error. How large heap did you configure in your project? Do you have enough RAM for that size of heap?

    But if all you need is one (1) object then I would not bother with any heap, since any use of the heap requires the runtime library to include the full heap implementation.

    A heap is best when you need a pool of a varying number of objects of varying size. If they all have the same size then it's better to use an array and just a flag to keep track of which elements in the array that are currently in use.