terrorsl / sMQTTBroker

Simple MQTT broker
MIT License
70 stars 19 forks source link

Memory usage #11

Closed conaito closed 1 year ago

conaito commented 3 years ago

I have add this onConnect: Serial.print("ESP32 FREE RAM: "); Serial.print(ESP.getFreeHeap() / 1024.0, 2); Serial.println("KB");

and connect and disconnect a client many times. As i can see the RAM goes smaller and smaller (even not much). May there is not correct free the memory on client disconnect? Can you double check that?

terrorsl commented 3 years ago
21:50:26.012 -> [D][sMQTTBroker.cpp:17] update(): New Client
21:50:26.012 -> [D][sMQTTClient.cpp:42] processMessage(): message type:Connect(0x10)
21:50:26.012 -> [D][sMQTTClient.cpp:75] processMessage(): message clientId:mqttx_12076250
21:50:26.012 -> [D][sMQTTClient.cpp:76] processMessage(): message keepTime:60
21:50:26.012 -> [D][uhome_base.cpp:219] onConnect(): ESP32 FREE RAM:230 KB
21:50:26.059 -> [D][sMQTTClient.cpp:42] processMessage(): message type:Subscribe(0x80)
21:50:26.059 -> [D][sMQTTClient.cpp:193] processMessage(): message id:27360
21:50:26.059 -> [D][sMQTTClient.cpp:202] processMessage(): message topic:homie/kitchen-light/cold/#
21:50:26.059 -> [D][sMQTTBroker.cpp:167] findRetainTopic(): findRetainTopic homie/kitchen-light/cold/# 0
21:50:31.005 -> [D][sMQTTClient.cpp:42] processMessage(): message type:Disconnect(0xe0)
21:50:31.005 -> ESP32 FREE RAM: 231KB
21:50:31.005 -> [D][sMQTTBroker.cpp:38] update(): Clients 0
21:50:34.194 -> [D][sMQTTBroker.cpp:17] update(): New Client
21:50:34.194 -> [D][sMQTTClient.cpp:42] processMessage(): message type:Connect(0x10)
21:50:34.194 -> [D][sMQTTClient.cpp:75] processMessage(): message clientId:mqttx_12076250
21:50:34.194 -> [D][sMQTTClient.cpp:76] processMessage(): message keepTime:60
21:50:34.194 -> [D][uhome_base.cpp:219] onConnect(): ESP32 FREE RAM:230 KB
21:50:34.240 -> [D][sMQTTClient.cpp:42] processMessage(): message type:Subscribe(0x80)
21:50:34.240 -> [D][sMQTTClient.cpp:193] processMessage(): message id:58121
21:50:34.240 -> [D][sMQTTClient.cpp:202] processMessage(): message topic:homie/kitchen-light/cold/#
21:50:34.240 -> [D][sMQTTBroker.cpp:167] findRetainTopic(): findRetainTopic homie/kitchen-light/cold/# 0
21:50:37.185 -> [D][sMQTTClient.cpp:42] processMessage(): message type:Disconnect(0xe0)
21:50:37.185 -> ESP32 FREE RAM: 231KB
21:50:37.185 -> [D][sMQTTBroker.cpp:38] update(): Clients 0

no leak

conaito commented 3 years ago

i will test it more and let you know. anyway main problem i have is the connection issue after a while of testing/playing with the broker. hope very much that you can find the issue. i will help, if i can with any required tests

conaito commented 3 years ago

here it looks like that:

[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 0 - WIFI_READY [D][WiFiGeneric.cpp:374] _eventCallback(): Event: 2 - STA_START [D][WiFiGeneric.cpp:374] _eventCallback(): Event: 4 - STA_CONNECTED [D][WiFiGeneric.cpp:374] _eventCallback(): Event: 7 - STA_GOT_IP [D][WiFiGeneric.cpp:419] _eventCallback(): STA IP: 192.168.178.46, MASK: 255.255.255.0, GW: 192.168.178.1 Connection established! IP address: 192.168.178.46 [D][sMQTTBroker.cpp:17] update(): New Client [D][sMQTTClient.cpp:42] processMessage(): message type:Connect(0x10) [D][sMQTTClient.cpp:75] processMessage(): message clientId:MQTTool7863377 [D][sMQTTClient.cpp:76] processMessage(): message keepTime:60 S273.37 KB onConnect: MQTTool7863377 [D][sMQTTClient.cpp:42] processMessage(): message type:Disconnect(0xe0) onRemove: MQTTool7863377 [D][sMQTTBroker.cpp:38] update(): Clients 0 [D][sMQTTBroker.cpp:17] update(): New Client [D][sMQTTClient.cpp:42] processMessage(): message type:Connect(0x10) [D][sMQTTClient.cpp:75] processMessage(): message clientId:MQTTool7863377 [D][sMQTTClient.cpp:76] processMessage(): message keepTime:60 273.21 KB onConnect: MQTTool7863377 [D][sMQTTClient.cpp:42] processMessage(): message type:Disconnect(0xe0) onRemove: MQTTool7863377 [D][sMQTTBroker.cpp:38] update(): Clients 0 [D][sMQTTBroker.cpp:17] update(): New Client [D][sMQTTClient.cpp:42] processMessage(): message type:Connect(0x10) [D][sMQTTClient.cpp:75] processMessage(): message clientId:MQTTool7863377 [D][sMQTTClient.cpp:76] processMessage(): message keepTime:60 272.92 KB onConnect: MQTTool7863377 [D][sMQTTClient.cpp:42] processMessage(): message type:Disconnect(0xe0) onRemove: MQTTool7863377 [D][sMQTTBroker.cpp:38] update(): Clients 0 [D][sMQTTBroker.cpp:17] update(): New Client [D][sMQTTClient.cpp:42] processMessage(): message type:Connect(0x10) [D][sMQTTClient.cpp:75] processMessage(): message clientId:MQTTool7863377 [D][sMQTTClient.cpp:76] processMessage(): message keepTime:60 272.76 KB onConnect: MQTTool7863377 [D][sMQTTClient.cpp:42] processMessage(): message type:PingReq(0xc0) [D][WiFiClient.cpp:514] connected(): Disconnected: RES: 0, ERR: 128 onRemove: MQTTool7863377 [D][sMQTTBroker.cpp:38] update(): Clients 0

terrorsl commented 2 years ago

ok, i check

terrorsl commented 2 years ago

21:40:16.761 -> [ 3161][V][WiFiServer.h:42] WiFiServer(): WiFiServer::WiFiServer(port=1883, ...) 21:40:44.870 -> [ 31285][D][sMQTTBroker.cpp:17] update(): New Client 21:40:44.870 -> [ 31288][D][sMQTTClient.cpp:47] processMessage(): message type:Connect(0x10) 21:40:44.916 -> [ 31288][D][sMQTTClient.cpp:80] processMessage(): message clientId:mqttx_12076250 21:40:44.916 -> [ 31293][D][sMQTTClient.cpp:81] processMessage(): message keepTime:60 21:40:44.963 -> [ 31367][D][sMQTTClient.cpp:47] processMessage(): message type:Subscribe(0x80) 21:40:44.963 -> [ 31367][D][sMQTTClient.cpp:201] processMessage(): message id:31018 21:40:44.963 -> [ 31369][D][sMQTTClient.cpp:210] processMessage(): message topic:homie/kitchen-light/cold/# 21:40:45.808 -> RAM:268448 21:41:00.018 -> [ 46421][D][sMQTTClient.cpp:47] processMessage(): message type:Disconnect(0xe0) 21:41:00.018 -> [ 46422][D][sMQTTBroker.cpp:44] update(): Clients 0 21:41:00.806 -> RAM:270768 21:41:41.835 -> RAM:270572 21:42:41.888 -> RAM:268864 21:42:42.919 -> RAM:270572 21:44:51.044 -> RAM:268864 21:44:52.027 -> RAM:270572 21:45:18.053 -> RAM:270552 21:45:19.080 -> RAM:270572 21:47:49.257 -> RAM:268864 21:47:50.248 -> RAM:270572 21:49:18.338 -> RAM:268864 21:49:19.321 -> RAM:270572 21:49:45.674 -> [572064][D][sMQTTBroker.cpp:17] update(): New Client 21:49:45.674 -> [572065][D][sMQTTClient.cpp:47] processMessage(): message type:Connect(0x10) 21:49:45.720 -> [572066][D][sMQTTClient.cpp:80] processMessage(): message clientId:mqttx_12076250 21:49:45.720 -> [572072][D][sMQTTClient.cpp:81] processMessage(): message keepTime:60 21:49:45.720 -> [572095][D][sMQTTClient.cpp:47] processMessage(): message type:Subscribe(0x80) 21:49:45.720 -> [572095][D][sMQTTClient.cpp:201] processMessage(): message id:1264 21:49:45.720 -> [572096][D][sMQTTClient.cpp:210] processMessage(): message topic:homie/kitchen-light/cold/# 21:49:46.380 -> RAM:268236 21:49:49.570 -> [575942][D][sMQTTClient.cpp:47] processMessage(): message type:Disconnect(0xe0) 21:49:49.570 -> [575943][D][sMQTTBroker.cpp:44] update(): Clients 0 21:49:50.369 -> RAM:270572 21:50:09.361 -> [595716][D][sMQTTBroker.cpp:17] update(): New Client 21:50:09.361 -> [595717][D][sMQTTClient.cpp:47] processMessage(): message type:Connect(0x10) 21:50:09.361 -> [595717][D][sMQTTClient.cpp:80] processMessage(): message clientId:mqttx_12076250 21:50:09.361 -> [595723][D][sMQTTClient.cpp:81] processMessage(): message keepTime:60 21:50:09.361 -> [595745][D][sMQTTClient.cpp:47] processMessage(): message type:Subscribe(0x80) 21:50:09.361 -> [595746][D][sMQTTClient.cpp:201] processMessage(): message id:32781 21:50:09.361 -> [595747][D][sMQTTClient.cpp:210] processMessage(): message topic:homie/kitchen-light/cold/# 21:50:09.409 -> RAM:266452 21:50:10.393 -> RAM:268244 21:50:15.045 -> [601436][D][sMQTTClient.cpp:47] processMessage(): message type:Disconnect(0xe0) 21:50:15.091 -> [601438][D][sMQTTBroker.cpp:44] update(): Clients 0 21:50:15.370 -> RAM:270572 21:50:34.393 -> RAM:270552 21:50:35.428 -> RAM:270572

github-actions[bot] commented 1 year ago

Stale issue message