What is the difference between multi_heap_free_size() and esp_get_free_heap_size()?
The documentation for the former says: 'Returns free heap size. Returns the number of bytes available in the heap.' For the latter: 'Returns the current size of free heap memory'.
Heap free size: multi_heap_free_size vs esp_get_free_heap_size
-
- Posts: 1725
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Heap free size: multi_heap_free_size vs esp_get_free_heap_size
multi_heap_free_size(...) is the lower-level function for querying one specific heap, identified via its handle. Normally, you don't manage heaps yourself and thus have no use for this function - and no heap handle for it in the first place.
As it says in the documentation:
As it says in the documentation:
esp_get_free_heap_size() is higher-level and returns the sum of free space over all heaps known to the multi-heap allocator.(Note: The multi-heap API is used internally by the heap capabilities allocator. Most ESP-IDF programs never need to call this API directly.)
Re: Heap free size: multi_heap_free_size vs esp_get_free_heap_size
Thanks for the clarification. I understand, just like esp_get_free_heap_size() is equals to heap_caps_get_free_size((MALLOC_CAP_DEFAULT))?MicroController wrote: ↑Thu Nov 09, 2023 11:55 ammulti_heap_free_size(...) is the lower-level function ...
Another question, is the heap_caps_print_heap_info() function also intended for internal use or simply for providing more detailed information than esp_get_free_heap_size()?
EDIT:
I found these lines in the source code:
Code: Select all
uint32_t esp_get_free_heap_size( void )
{
return heap_caps_get_free_size( MALLOC_CAP_DEFAULT );
}
uint32_t esp_get_free_internal_heap_size( void )
{
return heap_caps_get_free_size( MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL );
}
Who is online
Users browsing this forum: Baidu [Spider] and 376 guests