-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No memory leak in ESP8266WiFi... #7528
Comments
Thank you for your courteous help...;-) |
Fair enough @peychart , I probably should have explained the reason for closing. This was closed because you've posted a sample that doesn't compile, using an external library and headers, with a very vague OOM error report that's not reproducible outside of your own setup. So, there's really nothing we can do here. Your best bet is https://www.esp8266.com or the Gitter chat at https://gitter.im/esp8266/Arduino . If you can pull together a complete, failing MCVE we can give it a go, but w/o one (as said in the issue template) it's not going to be possible. |
809/5000 |
#7384 ## Platform
Settings in IDE
Problem Description
Mermory leak on WiFi use, particularly quickly in case of DNS problems, until the device reboot...
Hi friends and thank you for your work.
After several hours in google searching, I understood that there is no memory leak in the ESP8266WiFi library.
However, the fact remains that the device ends up rebooting, particularly quickly (every mn) when DNS (bind9) problems occur (on cut of internet link for example).
My use : https://github.com/peychart/WiFiPowerStrip/blob/master/Next-version/WiFiManager.cpp, line 109
MCVE Sketch
My project : https://github.com/peychart/WiFiPowerStrip/tree/master/Next-version
So, yes this project isn't very small (between 2k & 18k of free memory)... But, the punishment is the same with the lightweight C version of the prototype (https://github.com/peychart/WiFiPowerStrip) in operation for many months (stable most of the time, except on DNS failure - flashing house lighting)... :-(
Code:
#include <Arduino.h>
#include <ESP8266HTTPUpdateServer.h>
#include <uart.h>
#include "untyped.h" //<-- de/serialization object for JSON communications and backups on SD card
#include "WiFiManager.h" //<-- WiFi connection manager
#include "pins.h" //<-- pins object manager with serial pin extension manager
#include "switches.h" //<-- inputs management
#include "webPage.h" //<-- definition of a web interface
#ifdef DEFAULT_MQTT_BROKER
#include "mqtt.h" //<-- mqtt input/output manager
#endif
#ifdef DEFAULT_NTPSOURCE
#include "ntp.h" //<-- time-setting manager
#endif
#include "setting.h" //<--Can be adjusted according to the project...
#include "debug.h" //<-- telnet and serial debug traces
WiFiManager myWiFi;
...
void setup() {
...
myWiFi.version ( VERSION )
.onConnect ( onWiFiConnect )
.onStaConnect ( onStaConnect )
.ifStaConnected ( ifStaConnected )
.ifConnected ( ifWiFiConnected )
.onStaDisconnect ( onStaDisconnect )
.hostname ( DEFAULTHOSTNAME )
.setOutputPower ( 17.5 )
.restoreFromSD ();
...
}
void loop() {
ESPWebServer.handleClient(); delay(1L); //WEB server
myWiFi.loop(); //WiFi manager
mySwitches.inputEvent(intr, rebound_completed); //Switches management
myPins.timers(); //Timers control for outputs
myPins.serialEvent(); //Serial communication for the serial slave management
#ifdef DEFAULT_MQTT_BROKER
myMqtt.loop(); //MQTT manager
#endif
}
Debug Messages
no msg, device reboot on lack of memory...
FreeMem: 19000
FreeMem: 18808
FreeMem: 18768
FreeMem: 17800
FreeMem: 17736 //<- on every ESPWebServer.send call...
etc...
Workaround (but, not very elegant) :
#ifdef WIFI_MEMORY_LEAKS
struct tcp_pcb;
extern struct tcp_pcb* tcp_tw_pcbs;
extern "C" void tcp_abort (struct tcp_pcb* pcb);
inline void tcpCleanup(){while (tcp_tw_pcbs != NULL) tcp_abort(tcp_tw_pcbs);}
#endif
void ifWiFiConnected() { // run every 30s
#ifdef WIFI_MEMORY_LEAKS
ulong m=ESP.getFreeHeap();
DEBUG_print( F("FreeMem: ") ); DEBUG_print(m); DEBUG_print( F("\n") );
if( m < WIFI_MEMORY_LEAKS ){
ESPWebServer.stop(); ESPWebServer.close(); myWiFi.disconnect(1); //<- auto reconnect...
tcpCleanup();
ESPWebServer.begin();
DEBUG_print(F("TCP cleanup...\n"));
}
#endif
...
The text was updated successfully, but these errors were encountered: