Memory leak using timers
if you run the below code, you will see that after many loops it will raise "memory error". To reproduce in fastest way set SLEEP= 0.5. Same is with gc.enable().
import gc import utime from machine import Timer class Object: def __init__(self, count=0): print ("Object INIT ", self) self._timer = Timer.Alarm(self._timerCallback, 0.5, periodic=False) def __del__(self): print ("Object DEL ", self) def _timerCallback(self, timer): print("Timer finish " , self) self._timer.cancel() del self._timer self._timer = None print("Start memory %s" %(gc.mem_free())) SLEEP = 1.5 gc.disable() while True: obj = Object(100) utime.sleep(SLEEP) gc.collect() print("\t\tmemory %s" %(gc.mem_free()))
The issue was posted on github.
The most effective place to post bug reports is at https://github.com/pycom/pycom-micropython-sigfox/issues
The forum is mostly to discuss such bugs, since there's no issue tracking.