From 0fa76ee96e0432368c297a713b43772d3aecad49 Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Mon, 4 Aug 2025 16:33:21 +0800 Subject: [PATCH 1/2] fix(heap): fix a bug where the biggest heap would be NULL on boot Closes https://github.com/espressif/esp-idf/issues/17232 --- components/heap/heap_task_info.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/heap/heap_task_info.c b/components/heap/heap_task_info.c index 880bf358fd..8844e4fea8 100644 --- a/components/heap/heap_task_info.c +++ b/components/heap/heap_task_info.c @@ -57,12 +57,16 @@ FORCE_INLINE_ATTR heap_t* find_biggest_heap(void) heap_t *heap = NULL; heap_t *biggest_heap = NULL; SLIST_FOREACH(heap, ®istered_heaps, next) { - if (biggest_heap == NULL) { + /* In the case where we are currently looking for the biggest heap during startup, + * before the scheduler stated, all the memory regions marked as startup stacks will + * be NULL here. As such, they must be ignored. After boot up, this statement will + * never be true. */ + if (heap->heap == NULL) { + /* Continue the loop */ + } else if (biggest_heap == NULL) { biggest_heap = heap; } else if ((biggest_heap->end - biggest_heap->start) < (heap->end - heap->start)) { biggest_heap = heap; - } else { - // nothing to do here } } return biggest_heap; From 0226d42cbb9a47bdd322d4508d1278f351526600 Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Tue, 5 Aug 2025 09:35:54 +0800 Subject: [PATCH 2/2] fix: wrong name in the README file for advanced heap tracing example Closes https://github.com/espressif/esp-idf/issues/17233 --- examples/system/heap_task_tracking/advanced/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/system/heap_task_tracking/advanced/README.md b/examples/system/heap_task_tracking/advanced/README.md index ca8fe744d4..60184556e5 100644 --- a/examples/system/heap_task_tracking/advanced/README.md +++ b/examples/system/heap_task_tracking/advanced/README.md @@ -1,7 +1,7 @@ | Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-H4 | ESP32-P4 | ESP32-S2 | ESP32-S3 | | ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | --------- | -------- | -------- | -------- | -------- | -# Heap Task Tracking Basic Example +# Heap Task Tracking Advanced Example ## Overview @@ -10,7 +10,7 @@ The main then goes into a loop calling functions retrieving statistics for the " For each tasks, the following information is retrieved and printed: - the task name - the task status (running or deleted) - - the overall peak memory usage of the task + - the overall peak memory usage of the task - the overall current memory usage of the task For each heap used by a given task, the following information is printed: - the heap name