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

Memory leak #52

@syndycat

Description

@syndycat

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()))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions