From e85c093a0f053e1ef9c5a01eee020855069f024e Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Tue, 6 Jul 2021 01:55:16 +0200 Subject: [PATCH] Update heap memory calculation --- src/dev/esp32/esp32.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dev/esp32/esp32.cpp b/src/dev/esp32/esp32.cpp index 40520cd3..0904f7c0 100644 --- a/src/dev/esp32/esp32.cpp +++ b/src/dev/esp32/esp32.cpp @@ -238,19 +238,21 @@ void Esp32Device::update_backlight() size_t Esp32Device::get_free_max_block() { - return ESP.getMaxAllocHeap(); + // return ESP.getMaxAllocHeap(); + return heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); } size_t Esp32Device::get_free_heap() { - return ESP.getFreeHeap(); + // return ESP.getFreeHeap(); + return heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); } uint8_t Esp32Device::get_heap_fragmentation() { - uint32_t free = ESP.getFreeHeap(); + uint32_t free = get_free_heap(); if(free) { - return (int8_t)(100.00f - (float)ESP.getMaxAllocHeap() * 100.00f / (float)free); + return (int8_t)(100.00f - (float)get_free_max_block() * 100.00f / (float)free); } else { return 100; // no free memory }