MemoryUsage
Arduino library MemoryUsage
MemoryUsage.h File Reference
#include <stdint.h>

Go to the source code of this file.

Macros

#define MEMORY_PRINT_START   { Serial.print(F("Data start:")); Serial.println((int) &__data_start); }
 Print data start on serial console.
 
#define MEMORY_PRINT_HEAPSTART   { Serial.print(F("Heap start:")); Serial.println((int)&__heap_start); }
 Print data end / heap start on serial console.
 
#define MEMORY_PRINT_HEAPEND   { Serial.print(F("Heap end:")); Serial.println(__brkval == 0 ? (int)&__heap_start : (int)__brkval); }
 Print heap end / free ram area on serial console.
 
#define MEMORY_PRINT_STACKSTART   { Serial.print(F("Stack start:")); Serial.println((int) SP); }
 Print free ram end / stack start on serial console.
 
#define MEMORY_PRINT_END   { Serial.print(F("Stack end:")); Serial.println((int) RAMEND); }
 Print end of memory on serial console.
 
#define MEMORY_PRINT_HEAPSIZE   { Serial.print(F("Heap size:")); Serial.println((int) (__brkval == 0 ? (int)&__heap_start : (int)__brkval) - (int)&__heap_start); }
 Print heap size on serial console.
 
#define MEMORY_PRINT_STACKSIZE   { Serial.print(F("Stack size:")); Serial.println((int) RAMEND - (int)SP); }
 Print stack size on serial console.
 
#define MEMORY_PRINT_FREERAM   { Serial.print(F("Free ram:")); Serial.println((int) SP - (int) (__brkval == 0 ? (int)&__heap_start : (int)__brkval) - (int)&__heap_start); }
 Print free ram size on serial console.
 
#define MEMORY_PRINT_TOTALSIZE   { Serial.print(F("SRAM size:")); Serial.println((int) RAMEND - (int) &__data_start); }
 Print total SRAM size on serial console.
 
#define STACK_DECLARE   unsigned int mu_stack_size = (RAMEND - SP);
 Must be used only one time, outside any function.
 
#define STACK_COMPUTE   { mu_stack_size = (RAMEND - SP) > mu_stack_size ? (RAMEND - SP) : mu_stack_size;}
 Must be called to update the current maximum size of the stack, at each function beginning.
 
#define STACK_PRINT_TEXT(text)   { STACK_COMPUTE; Serial.print(text); Serial.println(mu_stack_size); }
 Compute the current maximum and show it now with customized text.
 
#define STACK_PRINT   STACK_PRINT_TEXT(F("Stack Maximum Size (Instrumentation method): "));
 Compute the current maximum and show it now with default text.
 
#define FREERAM_PRINT_TEXT(text)   Serial.print(text); Serial.println(mu_freeRam());
 Shows the current free SRAM memory with customized text.
 
#define FREERAM_PRINT   FREERAM_PRINT_TEXT(F("Free Ram Size: "));
 Shows the current free SRAM memory with default text.
 
#define STACKPAINT_PRINT_TEXT(text)   { Serial.print(text); Serial.println(mu_StackCount()); }
 Compute the current maximum and show it now with customized text.
 
#define STACKPAINT_PRINT   STACKPAINT_PRINT_TEXT(F("Stack Maximum Size (Painting method): "));
 Compute the current maximum and show it now with default text.
 

Functions

void SRamDisplay (void)
 Displays the 'map' of the current state of the Arduino's SRAM memory on the Serial console. More...
 
int mu_freeRam (void)
 Show the free Ram size on console.
 
uint16_t mu_StackCount (void)
 Show the stack size on console. More...
 

Variables

uint8_t _end
 
uint8_t __stack
 
uint8_t * __brkval
 
uint8_t * __data_start
 
uint8_t * __data_end
 
uint8_t * __heap_start
 
uint8_t * __heap_end
 
uint8_t * __bss_start
 
uint8_t * __bss_end
 

Detailed Description

Main library header file.

Definition in file MemoryUsage.h.

Function Documentation

uint16_t mu_StackCount ( void  )

Show the stack size on console.

Definition at line 72 of file MemoryUsage.cpp.

void SRamDisplay ( void  )

Displays the 'map' of the current state of the Arduino's SRAM memory on the Serial console.

Definition at line 83 of file MemoryUsage.cpp.