Memory Leaked at "Server.ino" example while testing...
GluTbl opened this issue · 1 comments
i used https://github.com/me-no-dev/ESPAsyncTCP/blob/master/examples/ClientServer/Server/Server.ino and upload to my esp8266
unsigned long mili = 0;
void loop() {
if (millis() - mili > 2000) {
mili = millis();
uint32_t free = system_get_free_heap_size();
Serial.print("\nFree Ram:");
Serial.print(free);
}
}
I add this line to check the free heap and for every request sent to ESP8266, the heap got decrease......
Free heap:47720
Free heap:47720
Free heap:47720
Free heap:47720
new client has been connected to server, ip: 192.168.4.2
data received from client 192.168.4.2
Hello World!
client (IP unset) disconnectedFree heap:47440
Free heap:47440
Free heap:47440
Free heap:47440
new client has been connected to server, ip: 192.168.4.2
data received from client 192.168.4.2
Hello World!
client (IP unset) disconnected
Free heap:47160
Free heap:47160
Free heap:47160
new client has been connected to server, ip: 192.168.4.2
data received from client 192.168.4.2
Hello World!
client (IP unset) disconnected
Free heap:46880
Free heap:46880
Free heap:46880
Free heap:46880
Okeey..... i solved it....
the client objects eat the heap.....
"https://github.com/me-no-dev/ESPAsyncWebServer/" i read the implementation of this library in this.
Close the client properly..... like the following at the time of disconnect
static void Server_handleDisconnect(void* arg, AsyncClient* client) {
Serial.printf("\n client %s disconnected \n", client->remoteIP().toString().c_str());
client->close(true);
client->free();
delete client;
}
and in the example the vector std::vector<AsyncClient*> clients;
will eat some heap.... just dont push the cleint if you dont need or else you need to manually clear the clients.