This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Description
LOPY 1.7.9.b3.
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 result 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()))