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_LISTENER 56 bool "sys_heap event notifications" 57 select HEAP_LISTENER 58 help 59 This allows application to listen for sys_heap events, 60 such as memory allocation and de-allocation. 61 62config HEAP_LISTENER 63 bool 64 help 65 Hidden option to enable API for registering and notifying 66 listeners of certain events related to a heap usage, 67 such as the heap resize. 68 69choice 70 prompt "Supported heap sizes" 71 depends on !64BIT 72 default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) 73 default SYS_HEAP_AUTO 74 help 75 Heaps using reduced-size chunk headers can accommodate so called 76 "small" heaps with a total size of 262136 bytes or less. 77 78 Heaps using full-size chunk headers can have a total size up to 79 16383 megabytes. The overhead is of course bigger. 80 81 On 32-bit system the tradeoff is selectable between: 82 83 - "small" heaps with low memory and runtime overhead; 84 85 - "big" heaps with bigger memory overhead even for small heaps; 86 87 - "auto" providing optimal memory overhead in all cases but with 88 a higher runtime overhead and somewhat bigger code footprint. 89 90 On 64-bit systems the "big" chunk header size conveniently provides 91 the needed alignment on returned memory allocations. Small chunk 92 headers would require alignment padding up to the big header size 93 anyway so "big" heap is the only option in that case. 94 95config SYS_HEAP_SMALL_ONLY 96 bool "Support for small heaps only" 97 help 98 Select this to optimize the code and memory usage if all your 99 heaps are 262136 bytes or less. 100 101config SYS_HEAP_BIG_ONLY 102 bool "Support for big heaps only" 103 help 104 Select this to optimize the code for big heaps only. This can 105 accommodate any heap size but memory usage won't be as 106 efficient with small sized heaps. 107 108config SYS_HEAP_AUTO 109 bool "Support for both small and big heaps at run time" 110 help 111 This option optimizes memory usage for each heap according to 112 their size albeit with some overhead in code size and execution. 113 114endchoice 115 116config MULTI_HEAP 117 bool "Multi-heap manager" 118 help 119 Allows multiple sys_heap regions to be unified under a single 120 allocation API. Sometimes apps need the ability to share multiple 121 discontiguous regions in a single "heap", or 122 to have memory of different "types" be allocated heuristically based 123 on usage (e.g. cacheability, latency, power...). This allows a 124 user-specified function to select the underlying memory to use for 125 each application. 126 127config SHARED_MULTI_HEAP 128 bool "Shared multi-heap manager" 129 select MULTI_HEAP 130 help 131 Enable support for a shared multi-heap manager that uses the 132 multi-heap allocator to manage a set of reserved memory regions with 133 different capabilities / attributes (cacheable, non-cacheable, 134 etc...) defined in the DT. 135 136endmenu 137