Skip to content
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

WiFi memory leak after disconnect (caused by log_d) ? #2033

Closed
kasskas opened this issue Nov 8, 2018 · 3 comments
Closed

WiFi memory leak after disconnect (caused by log_d) ? #2033

kasskas opened this issue Nov 8, 2018 · 3 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@kasskas
Copy link

kasskas commented Nov 8, 2018

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
@kasskas kasskas changed the title WiFi memory leak after disconnect ? WiFi memory leak after disconnect (caused by log_d) ? Nov 8, 2018
@felixstorm
Copy link
Contributor

[D][WiFiGeneric.cpp:342] _eventCallback(): Event: 7 - STA_GOT_IP has exactly 64 characters, so the leak is most likely caused by an issue in log_printf: #2232

me-no-dev pushed a commit that referenced this issue Dec 23, 2018
@stale
Copy link

stale bot commented 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 stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

2 participants