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.

What's the problem when it shows " ti.sysbios.heaps.HeapMem: line 296: out of memory: handle=0x822320, size=400 "

Other Parts Discussed in Thread: TMS320C6678, SYSBIOS

Hi all.

I am using TMS320C6678 and TMDXEVM6678LE to learn DSP. The bios is 6.32 and MCSDK is 2.0.5.17. To achieve my programming goal, I changed some codes in the mcip_master_main.c from the folder ...\mcsdk_2_00_05_17\demos\image_processing\ipc\master\src. As in my program, I want to use some global pointers. I declare these pointers out of the main function as follow: float *ptr1,  *ptr2, ..., *ptr15. In the main function, I use Memory_alloc() API to dynamic allocate some memory for each ptr as follow:

    ptr1= (float *) Memory_alloc(0, length_of_ptr1, 0, NULL);
    if(ptr1 == NULL)
    {
     printf("\nSystem doesn't allocate a pointer for ptr1!\n");
     exit(1);
    }
    printf("allocation done for ptr1\n");

After I download this program to  TMDXEVM6678LE , the first 11 pointers can be allocated, however the last 4 cannot be allocated. And it also shows

[C66xx_0] ti.sysbios.heaps.HeapMem: line 296: out of memory: handle=0x822320, size=400
[C66xx_0] xdc.runtime.Error.raise: terminating execution

Can anybody give some suggestions? Thanks in advance. 

  • Hi Haifei Wu,

    The message you are seeing means that you have used up all of the memory in your heap.  You can see this by opening the ROV tool (in CCS Tools menu -> ROV) and browsing to the HeapMem module, which will tell you the amount of free and used space in the heap.

    You can also increase the size of your heap within the demo *.cfg file "image_processing_evmc6678l_master.cfg".  The following code from that file is where the heap is created.

    In order to get around this problem, you need to increase the size of the heap for the image processing demo.  You can do this in the *.cfg file:

    /* Create a Heap. */
    var heapMemParams = new HeapMem.Params();
    heapMemParams.size = 0x8000000;                             // <-- edit this value to tune the size of the heap
    heapMemParams.sectionName = "systemHeapMaster";
    Program.global.heap0 = HeapMem.create(heapMemParams);
    Memory.defaultHeapInstance = Program.global.heap0;

    Once you change the above, rebuild and reload your app.

    Steve

  • Additionally, you should not pass NULL as the last parameter in Memory_alloc. This is an Error_Block. If you pass in NULL and there is no memory left, the program will terminate. If you pass in an initialized Error_Block and there is no memory, the Error_Block will be filled in with debug information and the Memory_alloc will return NULL.