This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Out of memory when doing a malloc() in dsp

I'm using TIs TDA3x and  Vision_SDK_2_9_0_0. I have tried allocating memory using malloc on DSP1 but gives me a out of memory error.

My malloc size is of an image i.e 1280*720

Then I tried to change the .cfg file and edited the heapMem size but it gives me below shown compile time error

C:/ti/vision_sdk/binaries/obj/vision_sdk/tda3xx-evm/c66xdsp_1/release/vision_sd
_configuro/linker_mod.cmd", line 201: error:
  program will not fit into available memory.  run placement with alignment
  fails for section ".fardata" size 0x592b8b .  Available memory ranges:
  DSP1_DATA_MEM   size: 0xd00000     unused: 0x2fc855     max hole: 0x2fc4ee
C:/ti/vision_sdk/binaries/obj/vision_sdk/tda3xx-evm/c66xdsp_1/release/vision_sd
_configuro/linker_mod.cmd", line 196: error:
  program will not fit into available memory.  placement with alignment fails
  for section ".cinit" size 0x392c21 .  Available memory ranges:
  DSP1_DATA_MEM   size: 0xd00000     unused: 0x1616a0     max hole: 0x161688
rror: errors encountered during linking;
  "C:/ti/vision_sdk/binaries/vision_sdk/bin/tda3xx-evm/vision_sdk_c66xdsp_1_re
  lease.xe66" not built

I'm totally new to TI platforms. Any help is appreciated...!!!

Thanks in advance...!!!

  • Hi Akash,

    So the problem seems to be you are trying to allocate more memory than you have available. I suggest you try decreasing the size of your Heap as the value you are setting seems to be too large.

    Thanks,
    Gerardo
  • Hi Akash,

    If decreasing your Heap doesn't give you enough space you may need to allocate the memory from a different location. If this is the case please provide me with your .cfg and map files so I can see what your current configuration is.

    Thanks,
    Gerardo

  • Use Utils_memAlloc Api with heap id UTILS_HEAPID_DDR_CACHED_SR for allocating big memories.

    Regards,

    Brijesh

  • I'm not clear with one thing...

    What is the exact difference between Utils_memAlloc Api and my normal malloc??
    If I have less memory available for my heap, than the memory I want to allocate how will memAlloc Api allocate... Does it allocates somewhere else... I'm not clear...

    Please share your view...
    ThankYou....!!!
  • Hi Gerardo,
    Thanks for your quick reply...

    As I said my default heap size was 0x80000 which I made 0x90000 , it worked fine..!!!
    Then I needed more memory so I made 0x160000, but compilation failed
    I then tried some more different sizes but the compilation gave the above error...

    Then I tried 0x500000 and now it is working fine...!!!
    I don't understand what is happening here... May be some alignment issues with the memory...

    Which are the possible values and what is the maximum value???

    Any help on this will be of great help...
    Thanks in advance...!!!!
  • Hi Akash,

    That is some odd behavior that you are seeing, would you mind sharing your .cfg and map files? That may help shed some light on what the issue may be.

    Thanks,
    Gerardo
  • Hi Akash,

    So it looks like when you set a bigger heap size the memory is allocated from a different section of memory that's why it works. You could try specifying the section from where it is allocated manually so that you would be able to set your heap size back to a smaller value. You can do this by using:

    // Section name for the buffer managed by the instance
    params.sectionName = String null;
    

    To set the section you want to allocate from. You can find all the configuration settings by going to the BIOS API at:
    <tirtos_install_dir>\products\<bios>\docs\Bios_APIs.html
    Then go to:
    ti->sysbios->heaps->HeapMem
    And clicking on Configuration settings.

    Thanks,
    Gerardo

  • Thanks for your reply...!!!

    The procedure you have specified, do I need ccs for that???, because I'm currently not using ccs...

    Is there some another way to do it... I'm using VisionSDK and compiling from command line...

    Further, what are the different sources of memory??

    What is the max_size I can allocate for Heap..??

  • Hi Akash,

    No you would do this in your .cfg file, just like you are setting the size. You would use the same parameters variable you are currently using so it would look something like:

    heapMemParams.sectionName

    The memory could be allocated from the internal memory or the external one. Your device has a big external memory so you would want to allocate any big chunks from there. In this case the big chunk you allocated is from DSP1_DATA_MEM which is the external RAM. Your max size would depend on how much memory you actually have available, you can find out by looking at your map file for DSP1_DATA_MEM.

    Thanks,
    Gerardo

  • "C:/ti/vision_sdk/binaries/obj/vision_sdk/tda2xx-evm/ipu1_0/release/vision_sdk_configuro/linker_mod.cmd", line 268: error:
    program will not fit into available memory. run placement with alignment
    fails for section "GROUP_1" size 0x147dba7 . Available memory ranges:
    IPU1_0_DATA_MEM size: 0xd00000 unused: 0x9f8d84 max hole: 0x9f8d70
    error: errors encountered during linking;
    "C:/ti/vision_sdk/binaries/vision_sdk/bin/tda2xx-evm/vision_sdk_ipu1_0_relea
    se.xem4" not built

    This is the error I'm getting when I increase the heap size further from 0x500000...!!!
    I'm skeptical about what it means by GROUP_1 section...
    Strange thing is I have two systems (i.e TDA2x) and I can increase the size on one board but cannot increase it on another...

    Suggestions are appreciated... !!
    URGENT...!!!
  • "C:/ti/vision_sdk/binaries/obj/vision_sdk/tda2xx-evm/ipu1_0/release/vision_sdk_configuro/linker_mod.cmd", line 268: error:
    program will not fit into available memory. run placement with alignment
    fails for section "GROUP_1" size 0x147dba7 . Available memory ranges:
    IPU1_0_DATA_MEM size: 0xd00000 unused: 0x9f8d84 max hole: 0x9f8d70
    error: errors encountered during linking;
    "C:/ti/vision_sdk/binaries/vision_sdk/bin/tda2xx-evm/vision_sdk_ipu1_0_relea
    se.xem4" not built

    This is the error I'm getting when I increase the heap size further from 0x500000...!!!
    I'm skeptical about what it means by GROUP_1 section...
    I'm trying to increase size of IPU1_0...

    I need to know maximum possible size for heap...
    I atleast need a heap size of 20Mb at initialization for my code to execute...


    Suggestions are appreciated... !!
    URGENT...!!!
  • Hi Akash,

    You can look on your map file to see how much memory you have available to allocate, with the map file you posted earlier you had 0x005be13c available in DSP1_DATA_MEM. You should use this file to figure out what you max allocation can be. You can also see which sections of memory have space available, as you increased the size it is trying to allocate from IPU1_0_DATA_MEM which has 0x00d00000 availble. To prevent this from happenning you can find a section that has enough memory to allocate what you need and specify your
    heapMemParams.sectionName to use this.

    Thanks,
    Gerardo