Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

M4 Airlift Serial.print output buffer eating memory ?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

M4 Airlift Serial.print output buffer eating memory ?

by MNXR250R on Sat Mar 21, 2020 5:10 pm

The question is >> If I use Serial.print() without having any connection to an external serial receiver, is it possible that the Serial.print() eats up a little more RAM every time that I use the Serial.print() function ? Eventually the device runs out of RAM and locks up ?

Using the M4 Airlift with the Arduino IDE. My program stopped (locked) after four days of running. My program uses millis() to schedule events and I don't have any code that should be blocking the program. I have the Serial.print() function in the code so that if I chose I can hook up a monitor to see how things are going. My code does not look for or wait for a serial connection. It just prints to the instance created with Serial.begin() at a regular interval.

Today I set up a test NTP server and increased the frequency of all function calls hoping to reduce the failure(lockup) from 4 days down to something manageable. Lucky me, the lockup occurred in less than 30 minutes ! After the failure I removed any calls to Serial.print() and so far the program is still running (3 hours).

You can see the code at https://github.com/Koberek/Greenhouse. The Serial.print() functions start at line 121 of FunctionTesting.ino.

I'd appreciate any commentary on the code.

Thanks All !

Jeff

MNXR250R
 
Posts: 7
Joined: Fri Feb 07, 2020 10:15 pm

Re: M4 Airlift Serial.print output buffer eating memory ?

by MNXR250R on Sat Mar 21, 2020 5:47 pm

Update .... My hypothesis of the Serial.print() function locking up my M4 appears to be false. The M4 locked up very soon after posting this question. Ugh.

I'd still appreciate comments, but for the time I have to.... think about my next step. Ugh.

Jeff

MNXR250R
 
Posts: 7
Joined: Fri Feb 07, 2020 10:15 pm

Re: M4 Airlift Serial.print output buffer eating memory ?

by MNXR250R on Thu Mar 26, 2020 9:09 pm

Update. Still locking after several hours. Eliminated all function calls except two. One to send NTP request, and the other to decode the NTP response.

I said in my first post that I didn't have any "blocking" functions. I should restate that I don't use delay(). All the functions take time and especially the 18B20 OneWire interface. I have 9 sensors and I'm using what I would call a block-read of all 9 sensors in one function. That function takes 960ms so it definitely IS a blocker.

Thanks All

Jeff

MNXR250R
 
Posts: 7
Joined: Fri Feb 07, 2020 10:15 pm

Re: M4 Airlift Serial.print output buffer eating memory ?

by adafruit_support_mike on Sun Mar 29, 2020 5:24 am

Try adding diagnostic Serial.print() statements at the beginning of each function (or at key points in the code) to help get a better idea of when the code locks up. The more you know about the conditions near the beginning of a problem, the easier it is to find solutions.

Also see if you can force a failure.. being able to make something fail on demand is about 90% of the way to defining the solution.

adafruit_support_mike
 
Posts: 61442
Joined: Thu Feb 11, 2010 2:51 pm

Re: M4 Airlift Serial.print output buffer eating memory ?

by MNXR250R on Thu Apr 02, 2020 8:49 pm

Thank you adafruit_support_mike...

I do use the Serial.print everywhere to find the problems with my code. The problems I've had recently fully lock up the program, so Serial.print() can't run.

Currently I move one suspect function FROM loop() into another function CALLED from loop(). This has eliminated the "lockup". (details if interested).

Thanks again :)

Jeff

MNXR250R
 
Posts: 7
Joined: Fri Feb 07, 2020 10:15 pm

Please be positive and constructive with your questions and comments.