Introduction:
In a previous project, I used the ESP8266 with FreeRTOS and wanted to check the memory usage. However, after much effort, I was unable to succeed and had to temporarily give up. Now, while developing with the ESP32, I also need to monitor memory usage, primarily to test and monitor memory changes to prevent memory leaks.
1. First, enable this feature
2. Method One
// First, create a task to handle this operation separately
xTaskCreate(state_task, "state_task", 4096, NULL, 6, NULL);
// Callback function
static void state_task(void *pvParameters)
{
static char InfoBuffer[512] = {0};
while (1)
{
vTaskList((char *) &InfoBuffer);
printf("Task Name Task State Priority Remaining Stack Task ID\r\n");
printf("\r\n%s\r\n", InfoBuffer);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}
- Effect Diagram
3. Method Two
// First, create a task to handle this operation separately
xTaskCreate(state_task, "state_task", 4096, NULL, 6, NULL);
// Callback function
static void state_task(void *pvParameters)
{
static char InfoBuffer[512] = {0};
while (1)
{
vTaskGetRunTimeStats((char *) &InfoBuffer);
printf("\r\nTask Name Run Count Usage Rate\r\n");
printf("\r\n%s\r\n", InfoBuffer);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}
- Effect Diagram