Open sohaibqamar opened 1 month ago
Hi @sohaibqamar from the code you are sharing you are only calling esp_mqtt_client_stop
this will not clean all data from the mqtt client.
That is why you can call esp_mqtt_client_start
again to re-start the client.
To completely clean all data you need to call esp_mqtt_client_destroy
but you will need to re init the client.
Regarding the publishing, if you are using QoS > 1, you are likely seeing the outbox growing. Could you verify the outbox size?
Answers checklist.
General issue report
Environment
Development Kit: ESP32-S3 Espressif IoT Development Framework (ESP-IDF) 5.1.0 Project Configuration Development Env: VScode Operating System: Windows Power Supply: External, stable (checked on oscilloscope)
Problem Description:
The code below is my network_manager.c is used to deinitialize and initialize the wifi task based on the
network_change_counter
value. The idea is to switch between wifi interface and observe if there is any memory leakage between a wifi connectivity cycle. I'm having almost 800-900 bytes of memory leakage. The problem seems to be the MQTT component if I do not start the MQTT, there is no memory leakage when we initialize, deinitialize, and again initialize the wifi interface.network_manager.c
Below is my wifi_manager.c code
wifi_manager.c
Below is the code for mqtt_manager.c which is being initialized in the start using mqtt_app_start function
mqtt_manager.c
I'm printing the Internal Free heap size using
esp_get_free_internal_heap_size()
and every time I get connected to the MQTT broker and publish a message, there is a decrease in available heap size by almost 800-900 bytes.