ESP-MQTT Memory leak
Posted: Wed Sep 13, 2023 11:54 am
When trying to initialise and start the mqtt client within a FreeRTOS task, I experience memory leaks/corruption. These are the two commands run:
This happens even if I allocate over 50% of the heap to the task. I understand FreeRTOS operates on a task based stack and that these commands do their own dynamic heap allocation. However they are writing beyond the bounds and writing into variables from other components and task stacks somehow.
This seems to be a bug with the only workaround to not do it within a task. However, I would like to do it in a task so I can keep retrying without holding up the rest of my code.
Has anyone else experienced anything similar?
Code: Select all
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
Code: Select all
esp_mqtt_client_start(received_client);
This seems to be a bug with the only workaround to not do it within a task. However, I would like to do it in a task so I can keep retrying without holding up the rest of my code.
Has anyone else experienced anything similar?