classification
Title: Memory leaks in functions
Type: resource usage Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: inada.naoki, jdemeyer, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-05-03 17:54 by jdemeyer, last changed 2018-07-04 02:16 by inada.naoki. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8058 merged inada.naoki, 2018-07-03 10:16
Messages (4)
msg316125 - (view) Author: Jeroen Demeyer (jdemeyer) * Date: 2018-05-03 17:54
This is a memory leak:

>>> while True:
...    def f(): pass
...    f.__doc__ = f

This also:

>>> while True:
...     f = [].append                                                                                                                                                   
...     f.__module__ = f

This is because the classes "function" and "builtin_function_or_method" do not implement tp_clear.
msg320953 - (view) Author: INADA Naoki (inada.naoki) * (Python committer) Date: 2018-07-03 10:19
I'm not sure this should be backported to 3.6 and 2.7.
While this is a obvious bug, f.__module__ = f seems very unnatural.
msg320954 - (view) Author: Jeroen Demeyer (jdemeyer) * Date: 2018-07-03 10:23
> While this is a obvious bug, f.__module__ = f seems very unnatural.

Sure.
msg321009 - (view) Author: INADA Naoki (inada.naoki) * (Python committer) Date: 2018-07-04 02:16
New changeset 3c452404ae178b742967589a0bb4a5ec768d76e0 by INADA Naoki in branch 'master':
bpo-33418: Add tp_clear for function object (GH-8058)
https://github.com/python/cpython/commit/3c452404ae178b742967589a0bb4a5ec768d76e0
History
Date User Action Args
2018-07-04 02:16:14inada.naokisetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: - Python 2.7, Python 3.6, Python 3.7
2018-07-04 02:16:00inada.naokisetmessages: + msg321009
2018-07-03 10:23:35jdemeyersetmessages: + msg320954
2018-07-03 10:19:55inada.naokisetnosy: + inada.naoki
messages: + msg320953
2018-07-03 10:16:42inada.naokisetkeywords: + patch
stage: patch review
pull_requests: + pull_request7667
2018-05-03 18:33:40serhiy.storchakasetnosy: + serhiy.storchaka

versions: + Python 2.7, Python 3.6, Python 3.7, Python 3.8
2018-05-03 17:54:46jdemeyersettype: resource usage
components: + Interpreter Core
2018-05-03 17:54:23jdemeyercreate