Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue26659

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:slice() leaks memory when part of a cycle
Type:resource usageStage:resolved
Components:Interpreter CoreVersions:Python 3.6, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: Demur Rumed, Kevin Modzelewski, benjamin.peterson, georg.brandl, pitrou, python-dev, vstinner, yselivanov
Priority:normalKeywords:

Created on2016-03-28 20:07 byKevin Modzelewski, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Messages (3)
msg262582 -(view)Author: Kevin Modzelewski (Kevin Modzelewski)Date: 2016-03-28 20:07
The slice type doesn't participate in GC, which means that if you happen to create a cycle involving a slice, that cycle will never get freed.  Here's an example:def f():    l = []    l.append(slice(l))# Will consume memory without bound:while True:    f()This seems pretty hard to trigger accidentally, so it might not be a huge deal -- especially since it seems to have been around for a while.  (I only checked 2.7 and trunk though.)I think this could be solved by either having the slice class participate in GC (ie add tp_traverse and tp_clear methods), or maybe doing some type-filtering during slice_new().
msg262589 -(view)Author: Philip Dubé (Demur Rumed)*Date: 2016-03-29 03:50
Implementing tp_traverse & tp_clear seems to runs into complications due to slice_cache
msg263590 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2016-04-16 21:54
New changeset879da9400529 by Benjamin Peterson in branch '2.7':add gc support to slice (closes#26659)https://hg.python.org/cpython/rev/879da9400529New changeset9e2176d18965 by Benjamin Peterson in branch '3.5':add gc support to slice (closes#26659)https://hg.python.org/cpython/rev/9e2176d18965New changeset870fcc50f1bd by Benjamin Peterson in branch 'default':merge 3.5 (#26659)https://hg.python.org/cpython/rev/870fcc50f1bd
History
DateUserActionArgs
2022-04-11 14:58:29adminsetgithub: 70846
2016-04-16 22:52:29martin.pantersetversions: + Python 3.5
2016-04-16 21:54:40python-devsetstatus: open -> closed

nosy: +python-dev
messages: +msg263590

resolution: fixed
stage: resolved
2016-03-29 22:18:46vstinnersetnosy: +vstinner
2016-03-29 08:16:06SilentGhostsetnosy: +georg.brandl,pitrou,benjamin.peterson,yselivanov
2016-03-29 03:50:32Demur Rumedsetnosy: +Demur Rumed
messages: +msg262589
2016-03-28 20:07:30Kevin Modzelewskicreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp