Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Memory leak using timers

    Scheduled Pinned Locked Moved Issues & Bugs
    memoryleaklopy
    3 Posts 2 Posters 1.3k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      Colateral
      last edited by jmarcelino

      Hello,

      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 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()))
      
      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jmarcelino @Colateral
        last edited by jmarcelino

        @Colateral
        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.

        1 Reply Last reply Reply Quote 0
        • C Offline
          Colateral
          last edited by

          The issue was posted on github.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom