Memory usage of xTaskCreate() within a task
Memory usage of xTaskCreate() within a task
If I allocated x amount of stack for task 1, then task 1 calls xTaskCreate() to create task 2, giving it y amount of stack, then would the y amount come out of the x amount or not? My hope is not. When a task ends, the memory is released, correct? Thanks.
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: Memory usage of xTaskCreate() within a task
No. Task memory is allocated using malloc() (well, technically it's a version of malloc that only allocates from internal memory) and freed using free() when vTaskDelete() is called and the idle task gets the chance to clean up the task. In other words: The stack of the calling task is unaffected, and the memory will be returned to the heap after a task is cleaned up.
Re: Memory usage of xTaskCreate() within a task
Thanks. Should the task call vTaskDelete itself before returning?
Regarding internal memory, is wrover psram considered internal? What memory is not internal?
Regarding internal memory, is wrover psram considered internal? What memory is not internal?
Re: Memory usage of xTaskCreate() within a task
- vTaskDelete() itself does not return the memory when deleting a current running task. The memory is instead free in the IDLE task.
- SPI RAM is not internal
Re: Memory usage of xTaskCreate() within a task
Thanks for clarifying. Then what does the psram do in wrover modules? Hash space other than task stacks, like allocating large memory blocks? Could you point me to some documentation on different ESP32 memories and psram?
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: Memory usage of xTaskCreate() within a task
Yes, exactly. You retrieve blocks of memory using malloc() and friends, so it gets used anywhere where large blocks of memory are allocated this way.
Re: Memory usage of xTaskCreate() within a task
So If I enable psram in menuconfig and compile my code, then psram gets automatically used whenever malloc() runs? Thanks.
Who is online
Users browsing this forum: Baidu [Spider], Bing [Bot] and 139 guests