1# Copyright (c) 2021 Intel Corporation 2# 3# SPDX-License-Identifier: Apache-2.0 4 5menu "Heap and Memory Allocation" 6 7config SYS_HEAP_VALIDATE 8 bool "Internal heap validity checking" 9 depends on ASSERT 10 help 11 The sys_heap implementation is instrumented for extensive 12 internal validation. Leave this off by default, unless 13 modifying the heap code or (maybe) when running in 14 environments that require sensitive detection of memory 15 corruption. 16 17 Use for testing and validation only. 18 19config SYS_HEAP_STRESS 20 bool "General purpose heap stress test" 21 help 22 Stresses the heap. 23 24 Use for testing and validation only. 25 26config SYS_HEAP_INFO 27 bool "Heap internal structure information" 28 help 29 Enables support for printing heap internal structure 30 information to the console. 31 32 Use for debugging only. 33 34config SYS_HEAP_ALLOC_LOOPS 35 int "Number of tries in the inner heap allocation loop" 36 default 3 37 help 38 The sys_heap allocator bounds the number of tries from the 39 smallest chunk level (the one that might not fit the 40 requested allocation) to maintain constant time performance. 41 Setting this to a high level will cause the heap to return 42 more successful allocations in situations of high 43 fragmentation, at the cost of potentially significant 44 (linear time) searching of the free list. The default is 45 three, which results in an allocator with good statistical 46 properties ("most" allocations that fit will succeed) but 47 keeps the maximum runtime at a tight bound so that the heap 48 is useful in locked or ISR contexts. 49 50config SYS_HEAP_RUNTIME_STATS 51 bool "System heap runtime statistics" 52 help 53 Gather system heap runtime statistics. 54 55config SYS_HEAP_ARRAY_SIZE 56 int "Size of array to store heap pointers" 57 default 0 58 help 59 The size of the internal array to store heap pointers. The array 60 is filled with a heap pointer on every sys_heap_init() call. 61 One can then iterate through the array to get all heaps statistics 62 and to sum up the total memory allocated for all heaps. 63 64 The default array size is zero, which disables the feature. 65 To enable the feature, assign a value greater than zero. 66 67config SYS_HEAP_LISTENER 68 bool "sys_heap event notifications" 69 select HEAP_LISTENER 70 help 71 This allows application to listen for sys_heap events, 72 such as memory allocation and de-allocation. 73 74config HEAP_LISTENER 75 bool 76 help 77 Hidden option to enable API for registering and notifying 78 listeners of certain events related to a heap usage, 79 such as the heap resize. 80 81choice 82 prompt "Supported heap sizes" 83 depends on !64BIT 84 default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) 85 default SYS_HEAP_AUTO 86 help 87 Heaps using reduced-size chunk headers can accommodate so called 88 "small" heaps with a total size of 262136 bytes or less. 89 90 Heaps using full-size chunk headers can have a total size up to 91 16383 megabytes. The overhead is of course bigger. 92 93 On 32-bit system the tradeoff is selectable between: 94 95 - "small" heaps with low memory and runtime overhead; 96 97 - "big" heaps with bigger memory overhead even for small heaps; 98 99 - "auto" providing optimal memory overhead in all cases but with 100 a higher runtime overhead and somewhat bigger code footprint. 101 102 On 64-bit systems the "big" chunk header size conveniently provides 103 the needed alignment on returned memory allocations. Small chunk 104 headers would require alignment padding up to the big header size 105 anyway so "big" heap is the only option in that case. 106 107config SYS_HEAP_SMALL_ONLY 108 bool "Support for small heaps only" 109 help 110 Select this to optimize the code and memory usage if all your 111 heaps are 262136 bytes or less. 112 113config SYS_HEAP_BIG_ONLY 114 bool "Support for big heaps only" 115 help 116 Select this to optimize the code for big heaps only. This can 117 accommodate any heap size but memory usage won't be as 118 efficient with small sized heaps. 119 120config SYS_HEAP_AUTO 121 bool "Support for both small and big heaps at run time" 122 help 123 This option optimizes memory usage for each heap according to 124 their size albeit with some overhead in code size and execution. 125 126endchoice 127 128config MULTI_HEAP 129 bool "Multi-heap manager" 130 help 131 Allows multiple sys_heap regions to be unified under a single 132 allocation API. Sometimes apps need the ability to share multiple 133 discontiguous regions in a single "heap", or 134 to have memory of different "types" be allocated heuristically based 135 on usage (e.g. cacheability, latency, power...). This allows a 136 user-specified function to select the underlying memory to use for 137 each application. 138 139config SHARED_MULTI_HEAP 140 bool "Shared multi-heap manager" 141 select MULTI_HEAP 142 help 143 Enable support for a shared multi-heap manager that uses the 144 multi-heap allocator to manage a set of reserved memory regions with 145 different capabilities / attributes (cacheable, non-cacheable, 146 etc...) defined in the DT. 147 148endmenu 149