123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #include <stdint.h>
- #include "esp_system.h"
- #include <string.h>
- #include <stdbool.h>
- #include "esp_log.h"
- #include "freertos/xtensa_api.h"
- #include "freertos/FreeRTOSConfig.h"
- #include "freertos/FreeRTOS.h"
- #include "freertos/queue.h"
- #include "freertos/task.h"
- #include "esp_event.h"
- #include "tools.h"
- #include "trace.h"
- static const char TAG[] = "TRACE";
-
- size_t malloc_int = 0;
- size_t malloc_spiram =0;
- size_t malloc_dma = 0;
- void memtrace_print_delta(const char * msg, const char * tag, const char * function){
- size_t malloc_int_delta = heap_caps_get_free_size(MALLOC_CAP_INTERNAL) - malloc_int;
- size_t malloc_spiram_delta = heap_caps_get_free_size(MALLOC_CAP_SPIRAM) - malloc_spiram;
- size_t malloc_dma_delta = heap_caps_get_free_size(MALLOC_CAP_DMA) - malloc_dma;
- ESP_LOGW(TAG, "Heap internal:%zu (min:%zu)(chg:%d)/external:%zu (min:%zu)(chg:%d)/dma:%zu (min:%zu)(chg:%d) : %s%s%s%s%s",
- heap_caps_get_free_size(MALLOC_CAP_INTERNAL),
- heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL),
- malloc_int_delta,
- heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
- heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM),
- malloc_spiram_delta,
- heap_caps_get_free_size(MALLOC_CAP_DMA),
- heap_caps_get_minimum_free_size(MALLOC_CAP_DMA),
- malloc_dma_delta,
- STR_OR_BLANK(tag),
- tag?" ":"",
- STR_OR_BLANK(function),
- function?" ":"",
- STR_OR_BLANK(msg)
- );
- malloc_int = heap_caps_get_free_size(MALLOC_CAP_INTERNAL);
- malloc_spiram = heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
- malloc_dma = heap_caps_get_free_size(MALLOC_CAP_DMA);
- }
|