timum-viw / socket.io-client

A socket.io-client implementation for ESP8266 and Arduino
228 stars 90 forks source link

SocketIOClient is eating heap like hungry monster #56

Closed RobertHolscher closed 3 years ago

RobertHolscher commented 5 years ago

Hi I have succesfully implemented the Socket.io library into my ESP8266. I have noticed that when I am using and initializing the SocketIoClient, the heap is reduced from 20000 to 4500 When I am then receiving some calls and do some other computation, the heap is dangerously low and causing resets.

Why does it eat away so much heap by default and can this be reduced somewhere in the library ? Your help is appreciated

lulersoft commented 4 years ago

in void SocketIoClient::loop() ,add this code: std::vector(_packets).swap(_packets):

if(millis() - _lastPing > PING_INTERVAL) {
    _webSocket.sendTXT("2");
    _lastPing = millis();
    std::vector<String>(_packets).swap(_packets);//DC
}
GowthamGottimukkala commented 4 years ago

Hi I have succesfully implemented the Socket.io library into my ESP8266. I have noticed that when I am using and initializing the SocketIoClient, the heap is reduced from 20000 to 4500 When I am then receiving some calls and do some other computation, the heap is dangerously low and causing resets.

Why does it eat away so much heap by default and can this be reduced somewhere in the library ? Your help is appreciated

Hey! I am new to this. How can I check my heap? Any help is appreciated

coma0815 commented 4 years ago

Hey! I am new to this. How can I check my heap? Any help is appreciated

ESP.getFreeHeap(); Or to print it to the serial monitor: Serial.println(ESP.getFreeHeap(),DEC);