In a sketch I have, I use a few libraries and have discovered that a large amount of RAM is being consumed.
Is there a tool that can identify how this RAM is being allocated, e.g. which libraries, which piece of code?
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.
Sign up to join this communityIn a sketch I have, I use a few libraries and have discovered that a large amount of RAM is being consumed.
Is there a tool that can identify how this RAM is being allocated, e.g. which libraries, which piece of code?
I use this code for Heap memory of AVR (UNO, Mega, etc.):
int freeRam()
{
extern int __heap_start, *__brkval;
int v;
return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval);
}
To show heap memory just use Serial.print("Write here a name of the function from which you print it"); Serial.println(freeRam());
anywhere in the code.
Compiler shows stack memory but not the heap, so this code helps me to find exact place where my program uses too much of heap memory. I just print it in every suspicious place in my code.
I hope this will help.
F()
macro around strings that you are printing. Since you didn't post any code, it is hard to give better advice. – Nick Gammon♦ May 20 '16 at 23:06