Skip to content

Creating too many qstr's leads to large memory use #2280

@peterhinch

Description

@peterhinch

Also on Pyboard, ESP8266. Pasted at the REPL:

import pickle, gc, micropython
gc.collect()
micropython.mem_info()
count = 0
def bar():
    global count
    s = pickle.dumps(('result', str(count)))
    count += 1
    return pickle.loads(s)
for _ in range(1000):
    a = bar()
gc.collect()
micropython.mem_info()

This produces the following outcome with used increasing:

mem: total=10303, current=3127, peak=4908
stack: 4992 out of 80000
GC: total: 2072832, used: 4064, free: 2068768
 No. of 1-blocks: 70, 2-blocks: 10, max blk sz: 9
12997
mem: total=2260180, current=376780, peak=378293
stack: 4992 out of 80000
GC: total: 2072832, used: 21248, free: 2051584
 No. of 1-blocks: 74, 2-blocks: 10, max blk sz: 161
>>> 

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