Skip to content

Instantly share code, notes, and snippets.

@schollz
Created January 8, 2024 18:21
Show Gist options
  • Save schollz/5329b7d30c052c22f2af2b29cd0abcfd to your computer and use it in GitHub Desktop.
Save schollz/5329b7d30c052c22f2af2b29cd0abcfd to your computer and use it in GitHub Desktop.
#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