Hi
I'm using DSP/BIOS 5 in a C++ project for the C6748. If I wish to dynamically allocate memory at run time should I use MEM_alloc/MEM_free, ie, the DSP/BIOS library functions, or simply use C++ builtin new and delete operators and assume that the compiler will sort it out? Does the compiler automatically map new and delete C++ calls to MEM_alloc and MEM_free? If not are there any arguments for using one approach over the other, eg, does one approach give more control and/or better/more predictable heap management?
I am a bit wary about the likelihood and/or consequences of heap fragmentation. When using delete or MEM_free is the freed space available immediately? For example, if I request a 1 MB block of memory and, for arguments sake, am returned a pointer to the base of the heap. If I then free this memory and then immediately request another 1 MB block of memory then (assuming that I can guarantee no other tasks have made any other memory requests in the meantime) can I be guaranteed that I would always get back a pointer to the same block of memory or might I get a pointer, say, 1 MB into the heap? In other words if this process were to repeat over and over could I ever run out of memory? Clearly in an ideal world where, by design, the lifecycle of each memory allocation request never overlaps those of other memory allocation requests I would always be given back the same block of memory from the start of the heap and memory fragmentation and the possibility of running out of memory should never occur!
Many thanks in advance
Tim