tmr.wdclr() leaks memory when called too often
Posted: Sat Jun 13, 2015 7:07 am
When calling tmr.wdclr() to often it will leak memory.
Memory Leaking code
Code that do not leak:
Here i substitute the
tmr.wdclr()
with
if(x%1000) then
tmr.wdclr()
end
More info on this case can be found here:
viewtopic.php?f=24&t=3274&start=10#p18691
Memory Leaking code
Code: Select all
function 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
print(node.heap())
end
Code that do not leak:
Code: Select all
function 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
print(node.heap())
end
Here i substitute the
tmr.wdclr()
with
if(x%1000) then
tmr.wdclr()
end
More info on this case can be found here:
viewtopic.php?f=24&t=3274&start=10#p18691