Hi there,
Programming for my Arduino (in some kind of mix of C/C++), I noticed something weird.
Everytime I communicate through the serial port, I keep an eye on the SRAM usage. Normally, it ranges between 300~400 bytes. However, after adding a new routine (see below), I noticed it always jumped from 300~400 bytes of free memory to EXACTLY 1023. My hunch is that there's a problem.
This is the new routine
void NewRoutine(char *cmdd){
GSM.print(cmdd);
GSM.print(26, BYTE);
GSM.print(endl); // <-- added later
Serial.print(availableMemory());
}
And this is the MemoryCheck Routine
int availableMemory() {
int size = 1024;
byte *buf;
while ((buf = (byte *) malloc(--size)) == NULL);
free(buf);
return size;
}
Please note this: First, it didn't work. After I added the endl command, it worked magically, but then I noticed the memory issue.
Anyone got ideas for a workaround?