mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Create dedicated function for xPortGetFreeHeapSize() that only reports on DRAM. NONOS SDK API system_get_free_heap_size() relies on xPortGetFreeHeapSize() for the free Heap size. Possible breaking change for multiple Heap Sketches calling system_get_free_heap_size(); it will now always report free DRAM Heap size. Update and export umm_free_heap_size_lw() to report the free Heap size of the current Heap. Updated ESP.getFreeHeap() to use umm_free_heap_size_lw(). Updated build options to supply exported umm_free_heap_size_lw() via either UMM_STATS or UMM_INFO. Improved build option support via the SketchName.ino.globals.h method for Heap options: UMM_INFO, UMM_INLINE_METRICS, UMM_STATS, UMM_STATS_FULL, UMM_BEST_FIT, and UMM_FIRST_FIT. While uncommon to change from the defaults, you can review umm_malloc_cfgport.h for more details, which may help reduce your Sketch's size in dire situations. Assuming you are willing to give up some functionality. For debugging UMM_STATS_FULL can offer additional stats, like Heap low water mark (umm_free_heap_size_min()).
52 lines
1.5 KiB
C
52 lines
1.5 KiB
C
/* ----------------------------------------------------------------------------
|
|
* umm_malloc.h - a memory allocator for embedded systems (microcontrollers)
|
|
*
|
|
* See copyright notice in LICENSE.TXT
|
|
* ----------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef UMM_MALLOC_H
|
|
#define UMM_MALLOC_H
|
|
|
|
#include <stdint.h>
|
|
|
|
// C These includes are not in the upstream
|
|
#include "umm_malloc_cfg.h" /* user-dependent */
|
|
#include <osapi.h>
|
|
#include <heap_api_debug.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
#ifdef UMM_HEAP_EXTERNAL
|
|
extern void umm_init_vm(void *vmaddr, unsigned int vmsize);
|
|
#endif
|
|
#ifdef UMM_HEAP_IRAM
|
|
extern void umm_init_iram(void);
|
|
extern void umm_init_iram_ex(void *addr, unsigned int size, bool zero);
|
|
#endif
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
extern void umm_init(void);
|
|
extern void *umm_malloc(size_t size);
|
|
extern void *umm_calloc(size_t num, size_t size);
|
|
extern void *umm_realloc(void *ptr, size_t size);
|
|
extern void umm_free(void *ptr);
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
extern umm_heap_context_t *umm_push_heap(size_t heap_number);
|
|
extern umm_heap_context_t *umm_pop_heap(void);
|
|
extern int umm_get_heap_stack_index(void);
|
|
extern umm_heap_context_t *umm_set_heap_by_id(size_t which);
|
|
extern size_t umm_get_current_heap_id(void);
|
|
extern umm_heap_context_t *umm_get_current_heap(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* UMM_MALLOC_H */
|