cancel
Showing results for 
Search instead for 
Did you mean: 

ThreadX / AzRtos - garbage collection?

matt-crc
Associate III

Hello,

When a task has completed, does azRtos do any garbage collection?  (ie remove the task and recoup the memory pools)?  - OR - is it something the user has to do (even for system threads)?

mattcrc_0-1741629799624.png

If it is the latter and I have to take out the garbage, do you have an example of that (a task that monitors, deletes tasks and recovers pool memory)?

2 REPLIES 2
mbarg.1
Senior II

Enable stack usage and will help understand ...

YES and NO. it is up to you to decide if threads (and other resources) use static or allocated memory and if you can de-allocate or delete.

Stack size is fixed at threads creation and does not change; you have to delete, de-allocate memory, allocate new memory and create thread again if you need to change stack size.

@mbarg.1 

It seems that all the threads created in azrtos use a separate memory pool for each Component (threadx, usbx, filex, netx). When you spawn a thread under one of those components, it will allocate the stack in the appropriate memory pool. I would have assumed that since the memory pools are controlled by the system, it would do the garbage collection automatically.  But from the image in my first post, you can see a thread has completed, and it lingers there indefinitely. So it looks like I have to release the memory myself and delete the thread manually.

Just wondering if there are any examples out there, before having to re-invent the wheel.