Current Lua downloadable firmware will be posted here

User avatar
By xfoldvar
#75631 Hello every one. I think that i found a memory leak in MQTT Lua module. This leak is of exact size 112bytes. It is hapenning while ESP is trying to reconnect to the MQTT broker. Each connection attempt consumes 112bytes, which are never freed. Why is this hapenning? I paste example code bellow. Thanks for any help.

Code: Select alllocal m = nil
local mqttReconnectTimer = tmr.create()
local function handle_mqtt_error(client, reason)
    client:close() 
    mqttReconnectTimer:start()
end
local function handle_mqtt_connect(client)
     client:on("offline", handle_mqtt_error)
     client:on("message", messageArrived)
     client:lwt(config.MQTT['lw_topic'],config.MQTT['lw_message'],config.MQTT['qos'],0)       
     publishData(client,"data") 
end
local function mqtt_connect(client)
    print("connecting "..node.heap())
    client:close()
    client:connect(config.MQTT["ip"], config.MQTT["port"],config.MQTT["tls"], 0, handle_mqtt_connect, handle_mqtt_error)
end
function module.start()
     m = mqtt.Client(config.ID, config.MQTT['keepalive'], config.MQTT['user'], config.MQTT['pwd'])
     mqttReconnectTimer:register(1000, tmr.ALARM_SEMI, function()  mqtt_connect(m)  end)
     mqttReconnectTimer:start()
end