1menu "Heap memory debugging"
2
3    choice HEAP_CORRUPTION_DETECTION
4        prompt "Heap corruption detection"
5        default HEAP_POISONING_DISABLED
6        help
7            Enable heap poisoning features to detect heap corruption caused by out-of-bounds access to heap memory.
8
9            See the "Heap Memory Debugging" page of the IDF documentation
10            for a description of each level of heap corruption detection.
11
12        config HEAP_POISONING_DISABLED
13            bool "Basic (no poisoning)"
14        config HEAP_POISONING_LIGHT
15            bool "Light impact"
16        config HEAP_POISONING_COMPREHENSIVE
17            bool "Comprehensive"
18    endchoice
19
20    choice HEAP_TRACING_DEST
21        bool "Heap tracing"
22        default HEAP_TRACING_OFF
23        help
24            Enables the heap tracing API defined in esp_heap_trace.h.
25
26            This function causes a moderate increase in IRAM code side and a minor increase in heap function
27            (malloc/free/realloc) CPU overhead, even when the tracing feature is not used.
28            So it's best to keep it disabled unless tracing is being used.
29
30        config HEAP_TRACING_OFF
31            bool "Disabled"
32        config HEAP_TRACING_STANDALONE
33            bool "Standalone"
34            select HEAP_TRACING
35        config HEAP_TRACING_TOHOST
36            bool "Host-based"
37            select HEAP_TRACING
38    endchoice
39
40    config HEAP_TRACING
41        bool
42        default F
43        help
44            Enables/disables heap tracing API.
45
46    config HEAP_TRACING_STACK_DEPTH
47        int "Heap tracing stack depth"
48        range 0 0 if IDF_TARGET_ARCH_RISCV # Disabled for RISC-V due to `__builtin_return_address` limitation
49        default 0 if IDF_TARGET_ARCH_RISCV
50        range 0 10
51        default 2
52        depends on HEAP_TRACING
53        help
54            Number of stack frames to save when tracing heap operation callers.
55
56            More stack frames uses more memory in the heap trace buffer (and slows down allocation), but
57            can provide useful information.
58
59    config HEAP_USE_HOOKS
60        bool "Use allocation and free hooks"
61        help
62            Enable the user to implement function hooks triggered for each successful allocation and free.
63
64    config HEAP_TASK_TRACKING
65        bool "Enable heap task tracking"
66        depends on !HEAP_POISONING_DISABLED
67        help
68            Enables tracking the task responsible for each heap allocation.
69
70            This function depends on heap poisoning being enabled and adds four more bytes of overhead for each block
71            allocated.
72
73    config HEAP_TRACE_HASH_MAP
74        bool "Use hash map mechanism to access heap trace records"
75        depends on HEAP_TRACING_STANDALONE
76        default n
77        help
78            Enable this flag to use a hash map to increase performance in handling
79            heap trace records.
80
81            Keeping this as "n" in your project will save RAM and heap memory but will lower
82            the performance of the heap trace in adding, retrieving and removing trace records.
83            Making this as "y" in your project, you will decrease free RAM and heap memory but,
84            the heap trace performances in adding retrieving and removing trace records will be
85            enhanced.
86
87    config HEAP_TRACE_HASH_MAP_SIZE
88        int "The number of entries in the hash map"
89        depends on HEAP_TRACE_HASH_MAP
90        range 1 10000
91        default 10
92        help
93            Defines the number of entries in the heap trace hashmap. The bigger this number is,
94            the bigger the hash map will be in the memory. In case the tracing mode is set to
95            HEAP_TRACE_ALL, the bigger the hashmap is, the better the performances are.
96
97    config HEAP_ABORT_WHEN_ALLOCATION_FAILS
98        bool "Abort if memory allocation fails"
99        default n
100        help
101            When enabled, if a memory allocation operation fails it will cause a system abort.
102
103    config HEAP_TLSF_USE_ROM_IMPL
104        bool "Use ROM implementation of heap tlsf library"
105        depends on ESP_ROM_HAS_HEAP_TLSF
106        default y
107        help
108            Enable this flag to use heap functions from ROM instead of ESP-IDF.
109
110            If keeping this as "n" in your project, you will have less free IRAM.
111            If making this as "y" in your project, you will increase free IRAM,
112            but you will lose the possibility to debug this module, and some new
113            features will be added and bugs will be fixed in the IDF source
114            but cannot be synced to ROM.
115
116    config HEAP_PLACE_FUNCTION_INTO_FLASH
117        bool "Force the entire heap component to be placed in flash memory"
118        depends on !HEAP_TLSF_USE_ROM_IMPL
119        default n
120        help
121            Enable this flag to save up RAM space by placing the heap component in the flash memory
122
123            Note that it is only safe to enable this configuration if no functions from esp_heap_caps.h
124            or esp_heap_trace.h are called from ISR.
125endmenu
126