@@ -108,10 +108,8 @@ extern char _heap_start[];
108
108
extern UMM_HEAP_INFO ummHeapInfo ;
109
109
110
110
void ICACHE_FLASH_ATTR * umm_info ( void * ptr , int force );
111
- size_t ICACHE_FLASH_ATTR umm_free_heap_size_info ( void );
111
+ size_t ICACHE_FLASH_ATTR umm_free_heap_size ( void );
112
112
size_t ICACHE_FLASH_ATTR umm_max_block_size ( void );
113
- size_t ICACHE_FLASH_ATTR umm_block_size ( void );
114
-
115
113
#else
116
114
#endif
117
115
@@ -127,13 +125,16 @@ extern char _heap_start[];
127
125
*
128
126
* UMM_INFO_PRINT is enabled as part of selecting `Debug port: "Serial" or
129
127
* "Serial1"`. To make available all the time use '-D UMM_INFO_PRINT`.
128
+ *
129
+ * Status: Local Enhancement - addresses platform specific issue.
130
130
*/
131
- #if defined(DEBUG_ESP_PORT ) && !defined(UMM_INFO_PRINT )
131
+ #if defined(DEBUG_ESP_PORT ) && !defined(UMM_INFO_PRINT ) && defined(
10669
UMM_INFO )
132
132
#define UMM_INFO_PRINT
133
133
#endif
134
134
135
135
/*
136
136
* -D UMM_STATS :
137
+ * -D UMM_STATS_FULL
137
138
*
138
139
* This option provides a lightweight alternative to using `umm_info` just for
139
140
* getting `umm_free_heap_size`. With this option, a "free blocks" value is
@@ -144,18 +145,31 @@ extern char _heap_start[];
144
145
* example is when an app closely monitors free heap to detect memory leaks. In
145
146
* this case a single-core CPUs interrupt processing would have suffered the
146
147
* most.
148
+ *
149
+ * UMM_STATS_FULL provides additional heap statistics. It can be used to gain
150
+ * additional insight into heap usage. This option would add an additional 132
151
+ * bytes of IRAM.
152
+ *
153
+ * Status: TODO: Needs to be proposed for upstream.
147
154
*/
148
155
/*
149
156
#define UMM_STATS
150
157
#define UMM_STATS_FULL
151
158
*/
152
159
153
- #if defined(DEBUG_ESP_PORT ) && !defined(UMM_STATS ) && !defined(UMM_STATS_FULL )
154
- #define UMM_STATS_FULL
155
- #elif !defined(UMM_STATS ) && !defined(UMM_STATS_FULL )
160
+ /*
161
+ * For the ESP8266 we want at lest UMM_STATS built, so we have an ISR safe
162
+ * function to call for implementing xPortGetFreeHeapSize(), because umm_info()
163
+ * is in flash.
164
+ */
165
+ #if !defined(UMM_STATS ) && !defined(UMM_STATS_FULL )
156
166
#define UMM_STATS
157
167
#endif
158
168
169
+ #if defined(UMM_STATS ) && defined(UMM_STATS_FULL )
170
+ #undef UMM_STATS
171
+ #endif
172
+
159
173
#if defined(UMM_STATS ) || defined(UMM_STATS_FULL )
160
174
161
175
typedef struct UMM_STATISTICS_t {
@@ -191,6 +205,10 @@ static inline size_t ICACHE_FLASH_ATTR umm_get_oom_count( void ) {
191
205
#define STATS__OOM_UPDATE () (void)0
192
206
#endif
193
207
208
+ #if defined(UMM_STATS ) || defined(UMM_STATS_FULL ) || defined(UMM_INFO )
209
+ size_t ICACHE_FLASH_ATTR umm_block_size ( void );
210
+ #endif
211
+
194
212
#ifdef UMM_STATS_FULL
195
213
#define STATS__FREE_BLOCKS_MIN () \
196
214
do { \
@@ -285,10 +303,6 @@ static inline size_t ICACHE_FLASH_ATTR umm_get_free_null_count( void ) {
285
303
#define STATS__FREE_REQUEST (tag ) (void)0
286
304
#endif
287
305
288
- #if defined(UMM_STATS ) || defined(UMM_STATS_FULL ) || defined(UMM_INFO )
289
- size_t umm_free_heap_size ( void );
290
- #endif
291
-
292
306
/*
293
307
Per Devyte, the core currently doesn't support masking a specific interrupt
294
308
level. That doesn't mean it can't be implemented, only that at this time
@@ -306,11 +320,12 @@ size_t umm_free_heap_size( void );
306
320
*
307
321
* Build option to collect timing usage data on critical section usage in
308
322
* functions: info, malloc, realloc. Collects MIN, MAX, and number of time IRQs
309
- * were disabled at request time. Note, for realloc MAX disabled time will not
310
- * include the time from calling malloc and/or free when UMM_LIGHTWEIGHT_CPU is
311
- * defined. Examine code for specifics on what info is available and how to
312
- * access.
313
- */
323
+ * were disabled at request time. Note, for realloc MAX disabled time will
324
+ * include the time spent in calling malloc and/or free. Examine code for
325
+ * specifics on what info is available and how to access.
326
+ *
327
+ * Status: TODO: Needs to be proposed for upstream.
328
+ */
314
329
/*
315
330
#define UMM_CRITICAL_METRICS
316
331
*/
@@ -402,11 +417,12 @@ static inline void _critical_exit(UMM_TIME_STAT *p, uint32_t *saved_ps) {
402
417
* UMM_CRITICAL_SUSPEND and UMM_CRITICAL_RESUME to the values of
403
418
* UMM_CRITICAL_EXIT and UMM_CRITICAL_ENTRY. These additional exit/entries
404
419
* allow time to service interrupts during the reentrant sections of the code.
405
- * Also, using these macros will relieve the nesting requirement.
406
420
*
407
- * These macros should probably not be used on multicore CPUs. Hardware locking
408
- * methods sometimes carry higher overhead and may not be suitable for frequent
409
- * calling.
421
+ * Performance may be impacked if used with multicore CPUs. The higher frquency
422
+ * of locking and unlocking may be an issue with locking methods that have a
423
+ * high overhead.
424
+ *
425
+ * Status: TODO: Needs to be proposed for upstream.
410
426
*/
411
427
/*
412
428
*/
@@ -428,6 +444,10 @@ static inline void _critical_exit(UMM_TIME_STAT *p, uint32_t *saved_ps) {
428
444
* shrinks an allocation, avoiding copy when possible. UMM_REALLOC_DEFRAG gives
429
445
* priority with growing the revised allocation toward an adjacent hole in the
430
446
* direction of the beginning of the heap when possible.
447
+ *
448
+ * Status: TODO: These are new options introduced to optionally restore the
449
+ * previous defrag propery of realloc. The issue has been raised in the upstream
450
+ * repo. No response at this time. Based on response, may propose for upstream.
431
451
*/
432
452
/*
433
453
#define UMM_REALLOC_MINIMIZE_COPY
@@ -503,6 +523,11 @@ static inline void _critical_exit(UMM_TIME_STAT *p, uint32_t *saved_ps) {
503
523
* include its nearest allocated neighbors in the heap.
504
524
* umm_malloc() will also checks the neighbors of the selected allocation
505
525
* before use.
526
+ *
527
+ * Status: TODO?: UMM_POISON_CHECK_LITE is a new option. We could propose for
528
+ * upstream; however, the upstream version has much of the framework for calling
529
+ * poison check on each alloc call refactored out. Not sure how this will be
530
+ * received.
506
531
*/
507
532
508
533
/*
@@ -571,6 +596,7 @@ static inline void _critical_exit(UMM_TIME_STAT *p, uint32_t *saved_ps) {
571
596
// PROGMEM. Only the 1st parameter, fmt, is supported in PROGMEM.
572
597
#define DBGLOG_FUNCTION (fmt , ...) ISR_PRINTF(fmt, ##__VA_ARGS__)
573
598
#define DBGLOG_FUNCTION_P (fmt , ...) ISR_PRINTF_P(fmt, ##__VA_ARGS__)
599
+
574
600
#else
575
601
#define DBGLOG_FUNCTION (fmt , ...) do { (void)fmt; } while(false)
576
602
#define DBGLOG_FUNCTION_P (fmt , ...) do { (void)fmt; } while(false)
@@ -646,38 +672,14 @@ void* ICACHE_RAM_ATTR pvPortMalloc(size_t size, const char* file, int line);
646
672
void * ICACHE_RAM_ATTR pvPortCalloc (size_t count , size_t size , const char * file , int line );
647
673
void * ICACHE_RAM_ATTR pvPortRealloc (void * ptr , size_t size , const char * file , int line );
648
674
void * ICACHE_RAM_ATTR pvPortZalloc (size_t size , const char * file , int line );
649
- void ICACHE_RAM_ATTR vPortFree (void * ptr , const char * file , int line );
650
675
#define malloc (s ) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; pvPortMalloc(s, mem_debug_file, __LINE__); })
651
676
#define calloc (n ,s ) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; pvPortCalloc(n, s, mem_debug_file, __LINE__); })
652
677
#define realloc (p ,s ) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; pvPortRealloc(p, s, mem_debug_file, __LINE__); })
653
- #if defined(UMM_POISON_CHECK ) || defined(UMM_POISON_CHECK_LITE )
654
- #if 0
655
- #define free (p ) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; vPortFree(p, mem_debug_file, __LINE__); })
656
- #endif
657
- #endif
658
678
659
679
#elif defined(UMM_POISON_CHECK ) || defined(UMM_POISON_CHECK_LITE )
660
680
#include <pgmspace.h>
661
-
662
681
void * ICACHE_RAM_ATTR pvPortRealloc (void * ptr , size_t size , const char * file , int line );
663
- void ICACHE_RAM_ATTR vPortFree (void * ptr , const char * file , int line );
664
-
665
682
#define realloc (p ,s ) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; pvPortRealloc(p, s, mem_debug_file, __LINE__); })
666
- #if 0
667
- //C
668
- /*
669
- Problem, I would like to report the file and line number with the umm poison
670
- event as close as possible to the event. The #define method works for malloc,
671
- calloc, and realloc those names are not as generic as "free". A #define free
672
- captures too much. Classes with methods called free are included :(
673
- Inline functions would report the address of the inline function in the .h
674
- not where they are called.
675
-
676
- Anybody know a trick to make this work?
677
- */
678
- #define free (p ) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; vPortFree(p, mem_debug_file, __LINE__); })
679
- #endif
680
-
681
683
#endif /* DEBUG_ESP_OOM */
682
684
683
685
#ifdef __cplusplus
0 commit comments