But your issue now is the memory not freed when the task is deleted, it is a different issue. The memory is freed by the idle task, that is stated in below link.
That's not the issue here. The issue is that, at least with _REENT_SMALL, the first call to a buffered I/O function will create file pointers for the stdio streams. FreeRTOS does call _reclaim_reent() when the task is deleted, but Newlib apparently doesn't free the stdio file pointers. Because the memory is not allocated as part of the TCB, FreeRTOS doesn't know about it and can't free it directly. I'm working that issue on the FreeRTOS forum.
Yes, the default runtime library is Redlib.
Here's what MCUX support said about Redlib:
Redlib was always designed as a simple, Embedded C library. And at present we have no plans to make it thread safe - we have seen little or no demand for this (in the 10 years or so that we have been supplying Redlib).
So Redlib is not thread safe but it's the default and the one recommended for use with FreeRTOS by NXP. What's the reasoning here? Does NXP consider the danger to be overstated? Does NXP assume that everyone knows that Redlib isn't thread safe and knows how to make it safe?
I had a product launch delayed by more than two months because of a race condition that turned out to be caused by a bug in the FreeRTOS kernel. It's incredibly frustrating trying to track down a crash that might not happen for days, and these devices need to be able to operate for years without maintenance, and some are installed in extremely remote locations. Knowing that my standard libraries are safe to use is not just an academic concern.
Thanks,
Scott