Created
January 8, 2024 18:21
-
-
Save schollz/5329b7d30c052c22f2af2b29cd0abcfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <malloc.h> | |
uint32_t getTotalHeap() { | |
extern char __StackLimit, __bss_end__; | |
return &__StackLimit - &__bss_end__; | |
} | |
uint32_t getFreeHeap() { | |
struct mallinfo m = mallinfo(); | |
return getTotalHeap() - m.uordblks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment