In my design, many sys_heap_alloc() would be used to push msg(data) to k_fifo.
but, it always return NULL and cause ASSERT..
the following is my code:
In my design, many sys_heap_alloc() would be used to push msg(data) to k_fifo.
but, it always return NULL and cause ASSERT..
the following is my code:
when the sys_heap_alloc fail to allocate memory. it sometimes report:
unexpected heap state
I really donot know what happened
Hi,
The heap will return NULL if you're out of memory for instance. Based on your statement:
I would call this frequently. sometimes it would works well.but it return NULL frequently.
This could be a possible source of the alloc operation failing due to space issues.
how to use the heap_alloc rightly?what requirement is need by SIZE?what requirement is need by len?
The API and usage of it is documented here: https://docs.zephyrproject.org/latest/kernel/memory_management/heap.html
brook said:unexpected heap state
This output?
https://github.com/nrfconnect/sdk-zephyr/blob/v3.3.99-ncs1-1/lib/os/heap.c#L176
That can indicate a double-free scenario. Are you potentially free'ing the same pointer in different contexts?
Kind regards,
Håkon