DSPRelated.com
Forums

Dynamic allocation of memory

Started by Laurent October 2, 2004

Hi,

I am trying to allocate some memory using the C malloc( ) function.
It works fine but it allocates it on the internal SRAM rather than on the
SDRAM.
Do you know how i could do dynamic memory allocation on the SDRAM ?

Actually, is there a way to have "2 mallocs", one that would allocate on the
SRAM and the other on the SDRAM ?

Also, i have read on the documentation that malloc( ) is not an optimal
function.
It's true that i only plan to do mallocs at the initialization stage of my
program, so that shouldn't be a problem.
But just out of curiosity, is there also a way to specify on which RAM i
allocate memory with VDK_MallocBlock( ) ?

Thanks,
Laurent





You could have 2 different user defined malloc subroutines; one for
internal memory and one for external memory. There are a lot of
different memory allocations schemes out there. Most have to do with
the granularity of the allocation and the difference between where and
how the allocation data(ie buffer pointer, allocated size, etc) for
the memory is defined. By the way, you'd also need two different free
subroutines to deallocate the different types of allocated memory.

ADI should provide all the source for it's malloc and free subroutines
in the lib/src folder. From these you can determine if they fit your
needs or not.

"It's true that i only plan to do mallocs at the initialization stage
of my program, so that shouldn't be a problem." Why are you using
dynamic memory?

Regards,
Tim Dahlin

--- In , "Laurent" <laurent@c...> wrote:
>
> Hi,
>
> I am trying to allocate some memory using the C malloc( ) function.
> It works fine but it allocates it on the internal SRAM rather than
on the
> SDRAM.
> Do you know how i could do dynamic memory allocation on the SDRAM ?
>
> Actually, is there a way to have "2 mallocs", one that would
allocate on the
> SRAM and the other on the SDRAM ?
>
> Also, i have read on the documentation that malloc( ) is not an optimal
> function.
> It's true that i only plan to do mallocs at the initialization stage
of my
> program, so that shouldn't be a problem.
> But just out of curiosity, is there also a way to specify on which RAM i
> allocate memory with VDK_MallocBlock( ) ?
>
> Thanks,
> Laurent