CCSv4.2.4, BIOS 6.31.4.27, IPC 1.22.3.23, Processor C6472
I noticed that HeapMem_alloc causes an abort when asked to allocate more memory than available. I've checked the ti.sysbios.heaps.HeapMem documentation and it does not discuss what happens when there is no heap available. I am stepping through the code and when it steps over HeapMem_alloc(), the abort information is output on the console window.
When I decrease the size of requested LL2 heap, it works fine.
If an abort is the expected response, is there a way to tie our own error callback to the abort?
Cheers
Eddie,
Is the HeapMem_alloc() being called from your code? if so, you could pass in an error block into the call and it shouldn't abort. If you pass "NULL" as the error block then it does abort. There's no callback function you can tie to abort. You would have to write your own xdc.runtime.ISystemSupport module to do this.
Judah
If my reply answers your question please mark the thread as answered
Ah!
Could you point me to the documentation on this behavior? I checked in ti.sysbios.heaps.HeapMem
C:\Program Files\Texas Instruments\bios_6_31_04_27\docs\cdoc\index.html
Eddie --
Do avoid the abort, you should do the following:
{ Error_Block eb;
Error_init(&eb); ptr = HeapMem_alloc(heap, size, align, &eb);
-Karl-
Same for HeapMemMP_alloc?
Yes, I see that:
Ptr ti_sdo_ipc_heaps_HeapMemMP_alloc(ti_sdo_ipc_heaps_HeapMemMP_Object *obj, SizeT reqSize, SizeT reqAlign, Error_Block *eb)
directly calls the XDC runtime function Error_raise(eb, ...), directly passing eb to it. This is the same behavior as HeapMem_alloc().
The Error_rasie() function will abort if the error block argument is NULL.
Steve
It must be a different IPC version you are using. I get this from the IPC_1_22_03_23 documentation. Unfortunately it does not state what happens when the alloc fails.
file:///C:/Program%20Files/Texas%20Instruments/ipc_1_22_03_23/docs/doxygen/html/_heap_mem_m_p_8h.html#a04ab3af78110251e5f22f9bc9a961a95
Allocate a block of memory of specified size and alignment.
The actual block returned may be larger than requested to satisfy alignment requirements.
HeapMemMP_alloc will lock the heap using the HeapMemMP gate while it traverses the list of free blocks to find a large enough block for the request.
Guidelines for using large heaps and multiple alloc() calls.
There are 2 APIs for HeapMemMP:
- ti/ipc/HeapMemMP is the public interface. This API is documented with doxygen. This API is portable to host side (Linux) and DSP side.
- ti/sdo/ipc/heaps/HeapMemMP is the internal implementation of the public implemenation. This module has a slightly different API from the public one.
The ti/ipc/HeapMemMP_alloc() API returns NULL on failure. I filed a bug report asking that we improve the documentation for this -- SDOCM00094029.