Skip to content

[BUG] Memory leak in __repr__ #59

@squahtx

Description

@squahtx

Similar to #55, __repr__ leaks memory.

OS version: Ubuntu 20.04.4 LTS
Python3 version (python3 -V -V): Python 3.8.10

Steps to reproduce

Borrowing code from #55:

import resource
import frozendict

print("frozendict version:", frozendict.__version__)
print()

c = 0
while True:
    fz = frozendict.frozendict({i: i for i in range(1000)})
    _repr = repr(fz)
    
    if (c % 10000) == 0:
        max_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
        print(f"iteration: {c}, max rss: {max_rss} kb")
    
    c += 1

Actual result

frozendict version: 2.3.2

iteration: 0, max rss: 11712 kb
iteration: 10000, max rss: 118104 kb
iteration: 20000, max rss: 224496 kb
iteration: 30000, max rss: 330888 kb
iteration: 40000, max rss: 437280 kb
iteration: 50000, max rss: 543672 kb

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions