Skip to content

Commit

Permalink
Introduce functions to dump the free mem from C code
Browse files Browse the repository at this point in the history
  • Loading branch information
obones authored and cpainchaud committed May 31, 2023
1 parent 0c76f6f commit 39dadc1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions RFLink/99_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

}
3 changes: 3 additions & 0 deletions RFLink/99_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 39dadc1

Please # to comment.