esp-idf/examples/system/heap_task_tracking
Guillaume Souchere 7492c862af feat(heap): Dissociate heap poisoning from task tracking
In order to enable CONFIG_HEAP_TASK_TRACKING, some kind
of poisoning had to be enabled (!HEAP_POISONING_DISABLED).
However since those functionalities don't seem to be related
in any way, this commit decouple them by removing
MULTI_HEAP_BLOCK_OWNER from poison_head_t in multi_heap_poisoning.c
and handling the block ownership in heap_caps.c instead.

Note that handling task tracking in multi_heap.c would necessitate
updating the ROM implementation of multi_heap.c as well. For this
reason, the task tracking feature has to be handled in heap_caps.c.
2023-10-18 06:43:22 +02:00
..
main esp_hw_support/esp_system: Re-evaluate header inclusions and include directories 2022-03-07 11:18:08 +05:30
CMakeLists.txt tools: Increase the minimal supported CMake version to 3.16 2022-06-01 06:35:02 +00:00
README.md feat(ci): Enable p4 example, test_apps and unit tests CI build 2023-08-24 12:51:19 +08:00
sdkconfig.defaults feat(heap): Dissociate heap poisoning from task tracking 2023-10-18 06:43:22 +02:00

Supported Targets ESP32 ESP32-C3 ESP32-C6 ESP32-P4 ESP32-S2 ESP32-S3

Heap Task Tracking Example

Overview

The example creates a task which allocates random amount of memory in each iteration and demonstrates use of internal API to get heap info on per task basis running in a system.

Heap task tracking feature has dependency on some of the internal heap debugging features (e.g. heap poisoning) which allows to store task control block in metadata of each heap block.

This adds small memory overhead on per heap block and hence this feature should be used for debugging purpose only.

Configure the project

To change the Heap Corruption Detection level, open the project configuration menu (idf.py menuconfig).

Navigate to Component config -> Heap memory debugging menu. In Heap corruption detection menu select either "Light Impact" or "Comprehensive".

Note: Enabling “Comprehensive” detection has a substantial runtime performance impact.

Build and Flash

Run idf.py -p PORT flash monitor to build and flash the project..

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

Task: Pre-Scheduler allocs -> CAP_8BIT: 5360 CAP_32BIT: 0
Task: esp_timer -> CAP_8BIT: 1724 CAP_32BIT: 0
Task: ipc0 -> CAP_8BIT: 8316 CAP_32BIT: 0
Task: main -> CAP_8BIT: 3480 CAP_32BIT: 0
Task: ipc1 -> CAP_8BIT: 12 CAP_32BIT: 0
Task: example_task -> CAP_8BIT: 696 CAP_32BIT: 0