From 39dadc16861030111001dc973bc4d603635db734 Mon Sep 17 00:00:00 2001 From: OBones Date: Thu, 3 Jun 2021 17:05:10 +0200 Subject: [PATCH] Introduce functions to dump the free mem from C code --- RFLink/99_helper.cpp | 21 +++++++++++++++++++++ RFLink/99_helper.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/RFLink/99_helper.cpp b/RFLink/99_helper.cpp index 7d2a5a37..db0893e2 100644 --- a/RFLink/99_helper.cpp +++ b/RFLink/99_helper.cpp @@ -18,5 +18,26 @@ void SerialPrint(int value) Serial.print(value); } +void SerialPrintFreeHeap() +{ + Serial.print(ESP.getFreeHeap()); +} + +void SerialPrintMaxAllocHeap() +{ + Serial.print(ESP.getMaxAllocHeap()); +} + +void SerialPrintFreeMemInfo() +{ + Serial.print("8bit aligned, Free = "); + Serial.print(heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); + Serial.print(", Max block = "); + Serial.print(heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); + Serial.print(", 32bit aligned, Free = "); + Serial.print(heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_32BIT)); + Serial.print(", Max block = "); + Serial.print(heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_32BIT)); +} } diff --git a/RFLink/99_helper.h b/RFLink/99_helper.h index 8121f509..155fc1bc 100644 --- a/RFLink/99_helper.h +++ b/RFLink/99_helper.h @@ -12,6 +12,9 @@ extern "C" { void SerialPrintLn(const char* msg); void SerialPrintMsg(const char* msg); void SerialPrint(int value); +void SerialPrintFreeHeap(); +void SerialPrintMaxAllocHeap(); +void SerialPrintFreeMemInfo(); #ifdef __cplusplus } #endif