MQTT IotMqtt_Subscribe memory leak

Hi all

I am still testing MQTT, now by connecting, subscribing to topics, and then closing the connection. I have memory leaks, one for each topic, with size = topicFilterLength. That made it relatively easy to find the cause…

IotMqtt_Subscribe() calls _IotMqtt_AddSubscriptions() where

pTopicFilter = IotMqtt_MallocMessage( pSubscriptionList[ i ].topicFilterLength );

IotMqtt_MallocMessage is pvPortMalloc.

I can’t find any place where pTopicFilter is again free-ed.

Am I doing something wrong (i.e. should I remove subscriptions before I close MQTT or when I receive a disconnect callback) or is this bug?

Thanks

W

Hi @wrm,

The topic filter is freed when removing the subscription. This was fixed recently in PR 3072, and you can pull the latest commit from the master branch for the updated code.

Thank you

Actually, I think we may have solved it. one of the python scripts was sending as QOS=2 (paho) and was causing RAM to fill up and retain messages, fast…

BTW, yes this was crashing mosquitto with out of ram errors within hours.

Edit: This was in the config file which should have mitigated what happened, but it didnt:

max_queued_bytes 1000
max_queued_messages 5