Left here for archival purposes.

User avatar
By andrewtholt
#39583 Hi,

I am new to nodeMCU, so this might be me

I'm seeing a memory leek in the MQTT client in NodeMCU 0.9.6 build 20150704

Here is my code, below

So it connects, and disconnects from an MQTT instance triggered by a timer.

What I see is the heap space gradually dropping until it reaches a critical level and then a reset.
The file is called "application.lua"

I run it with
Code: Select allapp=require("application")
app.start()


It's possible I'm doing something stupid, or maybe there is a leak

Regards,
Andrew

Code: Select alllocal module = {}

local function run()
    print("Heap start:" .. node.heap())
    if wifi.sta.status() == 5 and wifi.sta.getip() ~= nil then
        print("Connected")
        m = mqtt.Client(config.ID, 120)
        m:connect(config.HOST, config.PORT, 0, 1, function(con)
            print("Connected")
        end)

        m:close()
        m = nil
    else
        print ("Not connected")
    end
    print("Heap end  :" .. node.heap())
end

local function test()
    print("Heap start:" .. node.heap())
    print("Tick ...")
    print("Heap end  :" .. node.heap())
end

function module.start()
    tmr.stop(6)
    tmr.alarm(6,1000,1, run)
end

return module