There MUST be a heap to use xTaskCreate. If the heap is exhausted, then it will return an error code and not change the task handle it is given a pointer to (unless a malloc error handler has been defined to let you softly crash on out of memory).
As I have explained before, the address can be reused and cannot be the cause of the crash you are observing. Can you comment out your application code from tasks and see if you still observe the problem? Can you write a simple application to demonstrate the problem and share that?
Hi @aggarg , if i wait till the task handle is cleared before creating the task i don’t see the crash. But sometimes the wait is taking around 10 sec. I understood that task handle can be pointed to the same address. My question is if IDLE dose not clean the before allocated task handle pointer and after 2 times creating the task and deleting it, at 3ed time if the old pointer is allocated and the contents are not cleared will that create the crash?
If you have to wait 10 seconds, then your system seems to be stuck in a busy state, probably because some task is busywaiting rather than blocking for work.
Just because you recreate the task, shouldn’t cause problems. getting an old block that was free’d shouldn’t cause problems, unless somewhere your code is remembering old handles and assuming it is the same task.
You might run into running out of memory issues if you have a lot of task self-deleting and being re-created and your Idle task doesn’t get to run often enough to reclaim memory.
Thanks @richard-damon for all the information. I think i have a better view now.
No, it will not. As I have said before, the reason of the crash is something else.