This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Memory leak when defining a new class inside a loop
Type: resource usage Stage: resolved
Components: C API Versions: Python 3.9, Python 3.8, Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: pavlos kallis, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-04-15 08:36 by pavlos kallis, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
memory_leak.py pavlos kallis, 2020-04-15 08:36 Script to reproduce the memory leak
Messages (3)
msg366495 - (view) Author: pavlos kallis (pavlos kallis) Date: 2020-04-15 08:36
Running the script, memory starts to leak and garbage count increases.

Running the same script in python 2.7 does not cause the memory leak.
msg366503 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-15 09:38
Python2.7 gives similar results with:

    class A(object):
        pass
msg366504 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-04-15 10:20
It is not a leak. It is expected behavior when you call gc.set_debug(gc.DEBUG_SAVEALL).
History
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84472
2020-04-15 10:20:14serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg366504

resolution: not a bug
stage: resolved
2020-04-15 09:38:03rhettingersetnosy: + rhettinger
messages: + msg366503
2020-04-15 08:36:26pavlos kalliscreate