- Fri Jun 12, 2015 7:12 pm
#20304
I haven't found the time for more investigation until now but i have found a solution:
Original code from the first post)
Code: Select allfunction forwardandrewind()
if(forward == 1) then
forward = 0
gpio.write(3,gpio.HIGH)
else
forward = 1
gpio.write(3,gpio.LOW)
end
for x=1,16000 do
gpio.write(4,gpio.HIGH)
tmr.delay(1)
gpio.write(4,gpio.LOW)
tmr.delay(1)
tmr.wdclr()
end
tmr = nil
print(node.heap())
end
I found the problem with this code its the
tmr.wdclr() when called to often it leaks hell of memory instead it should only be called when needed.
example)
Code: Select allfunction forwardandrewind()
if(forward == 1) then
forward = 0
gpio.write(3,gpio.HIGH)
else
forward = 1
gpio.write(3,gpio.LOW)
end
for x=1,16000 do
gpio.write(4,gpio.HIGH)
tmr.delay(1)
gpio.write(4,gpio.LOW)
tmr.delay(1)
if(x%1000) then
tmr.wdclr()
end
end
tmr = nil
print(node.heap())
end
Here i substitute the
tmr.wdclr()with
if(x%1000) then
tmr.wdclr()
endand now it do not leak memory anymore....
So if someone else doing this foolish mistake then you got the solution for it