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 in dict.pop()
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Unbounded memory growth resizing split-table dicts
View: 28147
Assigned To: Nosy List: mgedmin, xiang.zhang
Priority: normal Keywords:

Created on 2016-12-07 14:47 by mgedmin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg282623 - (view) Author: Marius Gedminas (mgedmin) * Date: 2016-12-07 14:47
Run the following script with Python 3.6.0rc1:

    class O:
        pass

    o = O()
    for n in range(20):
        print(n)
        o.x = 42
        o.__dict__.pop('x', None)

You can observe the memory usage of the Python process growing exponentially.

E.g. in bash:

    ulimit -v 1000000    # don't push other processes into swap please
    python3.6 break.py
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Traceback (most recent call last):
      File "break.py", line 7, in <module>
        o.x = 42
    MemoryError
msg282624 - (view) Author: Marius Gedminas (mgedmin) * Date: 2016-12-07 14:48
If you're curious where this happens in real life, py.test's CaptureManager.deactivate_funcargs() does

    self.__dict__.pop("_capfuncarg", None)

and I found it by running 'tox -e py36' on https://github.com/mgedmin/eazysvn
msg282626 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-12-07 14:58
This is the same problem as #28147.
History
Date User Action Args
2022-04-11 14:58:40adminsetgithub: 73080
2016-12-07 14:58:58xiang.zhangsetstatus: open -> closed

superseder: Unbounded memory growth resizing split-table dicts

nosy: + xiang.zhang
messages: + msg282626
resolution: duplicate
stage: resolved
2016-12-07 14:48:45mgedminsetmessages: + msg282624
2016-12-07 14:47:11mgedmincreate