mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
feat(heap): Add feature to get peak heap usage
This feature keeps track of the per task peak memory usage. - Update the heap_task_tracking example to make use of the new feature Cleanup the implementation: - multi_heap_get_free_size() is never used, remove it. - Minor update in heap_caps_update_per_task_info_xx() funcitons. - Update settting on block owner in heap_caps.c to work with the get peak usage feature. - Update heap_caps_update_per_task_info_free() to detect when it is called to delete the memory allocated for a task TCB. Mark the corresponding task in the statistic list as deleted. - Add a Kconfig option dependant on HEAP_TASK_TRACKING being enabled that force the deletion of the statistics related to deleted task when set to true. - In task tracking feature, add a current and peak memory usage to the heap_stat_t structure to keep track of the current and peak memory usage of the given task across all heaps. - Fix missing block owner when allocating memory for heaps_array in heap_caps_init. - Keep the original implementation of the task tracking for backward compatibility reasons.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -32,7 +32,12 @@ void *multi_heap_aligned_alloc_offs(multi_heap_handle_t heap, size_t size, size_
|
||||
return multi_heap_aligned_alloc_impl_offs(heap, size, alignment, offset);
|
||||
}
|
||||
|
||||
#if (!defined CONFIG_HEAP_TLSF_USE_ROM_IMPL)
|
||||
size_t multi_heap_get_full_block_size(multi_heap_handle_t heap, void *p)
|
||||
{
|
||||
return multi_heap_get_allocated_size_impl(heap, p);
|
||||
}
|
||||
|
||||
#if(!defined CONFIG_HEAP_TLSF_USE_ROM_IMPL)
|
||||
/* if no heap poisoning, public API aliases directly to these implementations */
|
||||
void *multi_heap_malloc(multi_heap_handle_t heap, size_t size)
|
||||
__attribute__((alias("multi_heap_malloc_impl")));
|
||||
@@ -74,7 +79,6 @@ void *multi_heap_get_block_address(multi_heap_block_handle_t block)
|
||||
#define ALIGN_UP(X) ALIGN((X)+sizeof(void *)-1)
|
||||
#define ALIGN_UP_BY(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
|
||||
|
||||
|
||||
typedef struct multi_heap_info {
|
||||
void *lock;
|
||||
size_t free_bytes;
|
||||
|
Reference in New Issue
Block a user