Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak with Python 3.9 #38

Open
o-khytrov opened this issue Jul 23, 2022 · 1 comment
Open

Possible memory leak with Python 3.9 #38

o-khytrov opened this issue Jul 23, 2022 · 1 comment

Comments

@o-khytrov
Copy link

o-khytrov commented Jul 23, 2022

When frozendict is converted to string in python 3.9, it causes allocations of memory which can not be released with gc.collect()

import gc
import psutil
from frozendict import frozendict


def rss():
    return psutil.Process().memory_info().rss


def process(body):
    str(body)


if __name__ == '__main__':
    initial_memory = rss()
    for i in range(100000):
        payload = frozendict({"text": "Hello", "category": "electronics", "keyword": "electronics"})
        # payload = {"text": "Hello", "category": "electronics", "keyword": "electronics"}
        process(payload)

    print("memory before: ", initial_memory)
    gc.collect()
    print("memory after:  ", rss())

Result with frozendict

memory before:  13094912
memory after:   27693056

Result with builtin dictionary

memory before:  13086720
memory after:   13086720

@Marco-Sulla
Copy link

This repo is unmantained. Please look at Marco-Sulla/python-frozendict#59

mbakke pushed a commit to guix-mirror/guix that referenced this issue Nov 5, 2022
This fixes a potential memory leak with python 3.9:
slezica/python-frozendict#38

* gnu/packages/python-xyz.scm (python-frozendict): Update to 2.3.4.
[home-page]: Set to new upstream repository.

Signed-off-by: Christopher Baines <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants