Go Down

Topic: Memory usage statistics (Read 1 time) previous topic - next topic

Greg

Hi,
Does anyone have any code snippets for getting the amount of memory in use and also the total size of the memory dynamically? I've found the links to the AVR way, but couldn't find much for the Due.

Thanks,
Greg

cowasaki

I would find this useful too.


aethaniel

Hi Greg,

do you have the link about the AVR way?

cowasaki

AVR function:

Code: [Select]
// Returns the number of bytes currently free in RAM
static int freeRAM(void)
{
extern int  __bss_end;
extern int* __brkval;
int free_memory;
if (reinterpret_cast<int>(__brkval) == 0) {
   free_memory = reinterpret_cast<int>(&free_memory) - reinterpret_cast<int>(&__bss_end);
} else  {
   free_memory = reinterpret_cast<int>(&free_memory) - reinterpret_cast<int>(__brkval);
}
return free_memory;
}

Go Up