Skip to content

rp2: Memory error in thread allocation #7981

Closed

Description

@jimmo

Saw this on stackoverflow: https://stackoverflow.com/questions/69796458/is-there-a-memory-leak-in-micropython-hex-function

Here's a simple repro (that also shows the issue isn't with hex). If you run it with a smaller number of iterations (i.e. 0x1000) or not in a thread, it successfully runs to completion and prints "finished".

import _thread

def test():
    for i in range(0x1800):
        bytes(0)
    print("finished")

_thread.start_new_thread(test, ())

Note that it does successfully trigger an automatic collection, then fails about 144 allocations later. (Add print(gc.mem_free()) before the bytes(0) to see this).

Activity

  1. peterhinch commented on Nov 9, 2021

    @peterhinch
    Contributor

    See also this forum post.

  2. manpowre commented on Nov 12, 2021

    @manpowre

    See also this forum post.

    Its not the same issue, I tried this code here with gc.threshold(5423) and lower, and it still crashes.

  3. dpgeorge commented on Mar 1, 2022

    @dpgeorge
    Member

    Fixed by 2d47020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions