iotappstory / ESP-Library

Software Distribution and Management Over the Air
GNU Lesser General Public License v2.1
124 stars 35 forks source link

Possible memory leak? #189

Open EdMatheson opened 3 years ago

EdMatheson commented 3 years ago

First of all, I would like to complement you guys for an awesome app and web site. I can tell a lot of hard work went into it.

However, I have found an issue and I am not sure its a problem with the library or how I am using it. My apps in the field would start working erratically or crash after a few days of operation that included calling home. I found that the available heap was constantly being diminished over time. First, thinking my code was the problem, I begin to cut parts of my app trying to find the source of the problem. I finally got down to just the appstory code and still had the the issue. To confirm this, I made a very simple program (derived from your virgin soil example) that just used appstory to call home (every 10 minutes), blink an led once a second, and print the available heap every 100 seconds (code shown below). When run the available heap can be seen to slowly decrease until the code can't call home successfully and then finally dies.


define COMPDATE DATE TIME

define MODEBUTTON 0

include // IotAppStory.com library

IOTAppStory IAS(COMPDATE, MODEBUTTON); // Initialize IotAppStory

define ledPin 25 //for heltec

//#define ledPin 13 //for feather

// ================================================ SETUP ================================================ void setup() {

IAS.begin(); // Run IOTAppStory

IAS.setCallHomeInterval(600); //-------- Your Setup starts from here ---------------

//while (!Serial); // get serial ready Serial.begin(115200); delay(1000); Serial.println("Serial up"); Serial.println("This bare appstory ");

pinMode(ledPin, OUTPUT); }


The code was compiled with the latest Arduino IDE using the Arduino esp32 BSP ver 1.0.5 and the appstory library version 2.1.0-RCS5.1. It was executed on both an Adafruit ESP32 feather and a Heltec WiFi Kit 32 with the same results. Could you guys run my example and see if you can duplicate the issue or just give me a hint on where I am going wrong.

antonmeyer commented 2 years ago

I can confirm the same or similar issue. My project was tested several days with stable heap. Now with IOTAppStory heap is eaten within 40min, calling home every 60s.

Ends up in

Returning from IOTAppStory.com ------------------------------------------------------------------------- Calling Home

Checking for App(Sketch) updates from: https://iotappstory.com/ota/updates [E][ssl_client.cpp:36] _handle_error(): [start_ssl_client():207]: (-32512) SSL - Memory allocation failed [E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -32512 ERROR: connection failed

Checking for SPIFFS updates from: https://iotappstory.com/ota/updates [E][ssl_client.cpp:36] _handle_error(): [start_ssl_client():207]: (-32512) SSL - Memory allocation failed [E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -32512 ERROR: connection failed

Returning from IOTAppStory.com ------------------------------------------------------------------------- [E][ssl_client.cpp:36] _handle_error(): [start_ssl_client():138]: (-10368) X509 - Allocation of memory failed [E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -10368 InfluxDB write failed: connection refused Calling Home [E][EEPROM.cpp:136] begin(): Not enough memory for 16711680 bytes in EEPROM

Checking for App(Sketch) updates from: https://iotappstory.com/ota/updates Could not load Certificate! [E][EEPROM.cpp:136] begin(): Not enough memory for 0 bytes in EEPROM https://iotappstory.com/ota/updates Could not load Certificate!

Returning from IOTAppStory.com ------------------------------------------------------------------------- Calling Home [E][EEPROM.cpp:136] begin(): Not enough memory for 16711680 bytes in EEPROM

Checking for App(Sketch) updates from: https://iotappstory.com/ota/updates Could not load Certificate! [E][EEPROM.cpp:136] begin(): Not enough memory for 0 bytes in EEPROM https://iotappstory.com/ota/updates Could not load Certificate!

Returning from IOTAppStory.com

I will do some tests with examples. I had some problems with the initial setup of esp32 and IOTAppStory-Portal. I use board_build.partitions = min_spiffs.csv