Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Can You "malloc()" DMAMEM?

  1. #1
    Senior Member
    Join Date
    Feb 2017
    Posts
    299

    Can You "malloc()" DMAMEM?

    So, the DMAMEM directive is available to specify at compile-time time that a variable is to be stored in the lower RAM block. I'm wondering if there's a way to do the same thing with a dynamic allocation. I think the heap usually grows "up" (while the stack grows "down"). So, member it happens just due to that. Depends where it starts growing from.

    BTW, I'm just talking about T3.2, 3.5, 3.6 here.

    Thanks in advance.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,176
    With malloc you have no way to be sure where in the address space you'll get the memory allocated.

    It does grow upward, starting right after all the allocated variables. So if you static memory use is less than the size of the lower bank, then you can expect early calls to malloc to return memory from the lower bank. But if static usage has already claimed all of the lower bank, you'll never get malloc to return memory there. Likewise if other calls to malloc have used up the lower memory.

  3. #3
    Senior Member
    Join Date
    Feb 2017
    Posts
    299
    Thanks Paul.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •