Add heap info via standard mallinfo() function for STM32 (#7327)

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Chloe Bethel 2025-07-14 11:12:38 +01:00 committed by GitHub
parent 1be4fc5ae9
commit 3599ca6845
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,10 @@
#include "memGet.h"
#include "configuration.h"
#ifdef ARCH_STM32WL
#include <malloc.h>
#endif
MemGet memGet;
/**
@ -24,6 +28,9 @@ uint32_t MemGet::getFreeHeap()
return dbgHeapFree();
#elif defined(ARCH_RP2040)
return rp2040.getFreeHeap();
#elif defined(ARCH_STM32WL)
struct mallinfo m = mallinfo();
return m.fordblks; // Total free space (bytes)
#else
// this platform does not have heap management function implemented
return UINT32_MAX;
@ -42,6 +49,9 @@ uint32_t MemGet::getHeapSize()
return dbgHeapTotal();
#elif defined(ARCH_RP2040)
return rp2040.getTotalHeap();
#elif defined(ARCH_STM32WL)
struct mallinfo m = mallinfo();
return m.arena; // Non-mmapped space allocated (bytes)
#else
// this platform does not have heap management function implemented
return UINT32_MAX;