Hi all,
I wrote a rather large program on my mega and was wondering if generally 1.5K of free memory is enough to ensure a smooth ride. I know it depends on the amount of variables I use in my functions. But I think I am safe there... I was wondering is there anything else I need to concern myself with?
I included some very simple debug functions accessible via usb. I calculate my free memory with a function I found on this forum :
#ifdef __arm__
// should use uinstd.h to define sbrk but Due causes a conflict
extern "C" char* sbrk(int incr);
#else // __ARM__
extern char *__brkval;
#endif // __arm__
int freeMemory()
{
char top;
#ifdef __arm__
return &top - reinterpret_cast<char*>(sbrk(0));
#elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151)
return &top - __brkval;
#else // __arm__
return __brkval ? &top - __brkval : &top - __malloc_heap_start;
#endif // __arm__
}
I have not yet ran into unexpected behaviour but I'd ask it here anyway just to be on the safe side. And some of you always provide insight and advice I never thought of before.
kind regards, Kevin