Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue3667

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:Reloading an extension module always leaks
Type:Stage:
Components:Versions:Python 3.0
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: benjamin.petersonNosy List: amaury.forgeotdarc, barry, benjamin.peterson, loewis
Priority:release blockerKeywords:needs review, patch

Created on2008-08-24 20:54 byamaury.forgeotdarc, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
import-leak.patchamaury.forgeotdarc,2008-08-28 12:05
Messages (4)
msg71867 -(view)Author: Amaury Forgeot d'Arc (amaury.forgeotdarc)*(Python committer)Date: 2008-08-24 20:54
With python2.6, reloading extension modules does not always leak memory:Python 2.6b2+ (trunk, Aug 19 2008, 23:45:24) [MSC v.1500 32 bit (Intel)]on win32Type "help", "copyright", "credits" or "license" for more information.>>> import sys[34467 refs]>>> import audioop; del sys.modules['audioop'][34677 refs]>>> import audioop; del sys.modules['audioop'][34677 refs]But with 3.0, reloading audioop leaks 60 references every time (seen intest_unittest):Python 3.0b3+ (py3k, Aug 24 2008, 21:56:40) [MSC v.1500 32 bit (Intel)]on win32Type "help", "copyright", "credits" or "license" for more information.>>> import sys[42018 refs]>>> import audioop; del sys.modules['audioop'][42257 refs]>>> import audioop; del sys.modules['audioop'][42317 refs]>>> import audioop; del sys.modules['audioop'][42377 refs]>>> import audioop; del sys.modules['audioop'][42437 refs]>>> import audioop; del sys.modules['audioop'][42497 refs]OK, many things cannot be reinitialized for C-written modules (staticvariables &co), this is not the case for audioop. Furthermore, I thoughtthat the new module API was to support proper cleanup of modules
msg72085 -(view)Author: Amaury Forgeot d'Arc (amaury.forgeotdarc)*(Python committer)Date: 2008-08-28 12:05
The fix is actually simple: _PyImport_FindExtension() used to return aborrowed reference, the "strong" reference being stored in thePyImport_GetModuleDict() dictionary. All paths should behave the same.See attached patch.(for unit tests, run for example    regrtest.py -R:: test_site)
msg72466 -(view)Author: Barry A. Warsaw (barry)*(Python committer)Date: 2008-09-04 02:27
The patch looks good.  Benjamin will commit this.
msg72467 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2008-09-04 02:28
Fixed inr66204.
History
DateUserActionArgs
2022-04-11 14:56:38adminsetgithub: 47917
2008-09-04 02:28:32benjamin.petersonsetstatus: open -> closed
resolution: accepted -> fixed
messages: +msg72467
2008-09-04 02:27:54barrysetassignee:loewis ->benjamin.peterson
resolution: accepted
messages: +msg72466
nosy: +benjamin.peterson,barry
2008-08-30 17:18:13georg.brandlsetassignee:loewis
nosy: +loewis
2008-08-28 12:05:14amaury.forgeotdarcsetkeywords: +needs review,patch
files: +import-leak.patch
messages: +msg72085
2008-08-24 20:54:59amaury.forgeotdarccreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp