Closed
Description
Hardware:
Board: ESP32-WROOM
Core Installation/update date: 2018 Sep
IDE name: Arduino IDE
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10?
Description:
Every time WiFi client connects and disconnects, free memory in heap is reduced. After some time this causes a crash of the MCU. The issue happens using WiFiCLientBasic example code. Building without debug output seems to solve the issue. Could there be a possible leak in log_d output?
After some test with none debug out, it seems that log_d in WiFi begins leaks memory. Is there any known fixes ?
Sketch:
#include <WiFi.h>
#include <esp_wifi.h>
const char* ssid = "ssid";
const char* password = "pass";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi..");
}
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
WiFi.disconnect(true);
delay(500);
}
void loop() {
WiFi.begin();
/*while (WiFi.status() != WL_CONNECTED)
;*/
delay(10000);
WiFi.disconnect(true);
//Serial.print("after: ");
Serial.println(xPortGetFreeHeapSize());
delay(10000);
}
Debug Messages:
With log_d output
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:386] _eventCallback(): STA IP: 192.168.1.103, MASK: 255.255.255.0, GW: 192.168.1.1
after: 234380
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 3 - STA_STOP
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 3 - STA_STOP
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:386] _eventCallback(): STA IP: 192.168.1.103, MASK: 255.255.255.0, GW: 192.168.1.1
after: 234216
Without log_d output:
235248
235380
235384
235384
235240
235240
235236
235236
235384
235384
235384
235236
235236
235236
235236
235384
235380
235380
235236
235236
235220
235236
235384
235384
235384
235236
235236
235236
235236
Activity
[-]WiFi memory leak after disconnect ? [/-][+]WiFi memory leak after disconnect (caused by log_d) ? [/+]felixstorm commentedon Dec 22, 2018
[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 7 - STA_GOT_IP
has exactly 64 characters, so the leak is most likely caused by an issue inlog_printf
: #2232fix #2232 and #2033 (#2233)
stale commentedon Aug 1, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Aug 15, 2019
This stale issue has been automatically closed. Thank you for your contributions.