# vTaskDelete 

**URL:** <https://forums.freertos.org/t/vtaskdelete/6946>\
**Category:** Kernel\
**Created:** [January 16, 2018, 1:01pm UTC](https://forums.freertos.org/t/vtaskdelete/6946 "2018-01-16T13:01:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 16, 2018, 1:01pm UTC](https://forums.freertos.org/t/vtaskdelete/6946/1 "2018-01-16T13:01:29Z")

</div>

**[michaeln32](https://sourceforge.net/u/michaeln32/)** wrote on [Tuesday, January 16, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/28709627/#e64e):

Hi,  
I create a task using xTaskCreat();

Is it on my responsibility to free all memory usage before delete the task (using vTaskDelete()) or it is done automatically by freeRTOS kernel ?

Is it on my responsibility to free all task stack and task TCB before delete the task (using vTaskDelete()) or it is done automatically by freeRTOS kernel ?

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [January 16, 2018, 1:16pm UTC](https://forums.freertos.org/t/vtaskdelete/6946/2 "2018-01-16T13:16:25Z")

</div>

**[richard\_damon](https://sourceforge.net/u/richard_damon/)** wrote on [Tuesday, January 16, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/28709627/#3ddc):

vTaskDelete will delete the task stack and TCB (either immediately if deleting another task, or deferred to the I(dle task if a task is deleting itself), assuming the task was created with dynamic memory (for a statically created task, vTaskDelete() will have FreeRTOS stop using that space, so it is now available to use to create another static task), All other resorces that the task has allocated need to be handled by your program, as FreeRTOS doesn’t know if they are still needed.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 16, 2018, 4:11pm UTC](https://forums.freertos.org/t/vtaskdelete/6946/3 "2018-01-16T16:11:08Z")

</div>

**[michaeln32](https://sourceforge.net/u/michaeln32/)** wrote on [Tuesday, January 16, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/28709627/#337f):

I’m using NewLib instead of FreeRTOS heap.c for dynamic memory allocation algorithm.

NewLib dynamic memory allocation algorithm is different than FreeRTOS dynamic memory algorithm (heap.c).

Are the thinkgs above about the vTaskDelete() operations are the same if I use NewLib ?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [January 16, 2018, 4:30pm UTC](https://forums.freertos.org/t/vtaskdelete/6946/4 "2018-01-16T16:30:12Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, January 16, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/28709627/#337f/a237):

I recommend stepping through the very simple vTaskDelete() function in  
the debugger, or simply just looking at the short piece of source code  
that implements it, so you can see that Richard Damon’s clear answer is  
correct and holds in all cases - you will be able to see see exactly  
what the function does and does not do. FreeRTOS has no idea about any  
memory you allocated from Newlib.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 16, 2018, 4:41pm UTC](https://forums.freertos.org/t/vtaskdelete/6946/5 "2018-01-16T16:41:29Z")

</div>

**[michaeln32](https://sourceforge.net/u/michaeln32/)** wrote on [Tuesday, January 16, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/28709627/#8a2d):

Ok Thanks
