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.
Created on 2010年06月24日 19:32 by yappie, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| unnamed | yappie, 2010年06月24日 23:34 | |||
| Messages (3) | |||
|---|---|---|---|
| msg108545 - (view) | Author: Slava (yappie) | Date: 2010年06月24日 19:32 | |
I don't know whether this is a bug, but my exhaustive search led me to "Python can't really unload modules" from every direction, which I find hard to believe, I don't know where else to go with this. The problem: import gc, sys print len(gc.get_objects()) # 4073 # starting with 4073 objects in memory import httplib del sys.modules["httplib"] del httplib # httplib should be unloaded # and garbage collected as it is unreachable gc.collect() print len(gc.get_objects()) # 6745 # 6745 objects in memory (2000+ stray objects) This applies to almost any module. Is this a bug or somehow correctable? |
|||
| msg108558 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2010年06月24日 22:43 | |
This is not a bug. You didn't *nearly* reset Python to the state in which it was before the import: the modules that got imported recursively still hang in sys.modules. Please accept that Python indeed does not support unloading modules for severe, fundamental, insurmountable, technical problems, in 2.x. In 3.x, chances are slightly higher. In principle, unloading could be supported - but no module actually adds the necessary code, and the necessary code in the import machinery isn't implemented in 3.2 and earlier. Supporting unloading will be (and was) a multi-year project. Don't expect any results in the next five years. |
|||
| msg108566 - (view) | Author: Slava (yappie) | Date: 2010年06月24日 23:34 | |
Thank you for taking time to answer my question about unloading modules. I really appreciate it! Slava On Fri, Jun 25, 2010 at 2:43 AM, Martin v. Löwis <report@bugs.python.org>wrote: > > Martin v. Löwis <martin@v.loewis.de> added the comment: > > This is not a bug. You didn't *nearly* reset Python to the state in which > it was before the import: the modules that got imported recursively still > hang in sys.modules. > > Please accept that Python indeed does not support unloading modules for > severe, fundamental, insurmountable, technical problems, in 2.x. > > In 3.x, chances are slightly higher. In principle, unloading could be > supported - but no module actually adds the necessary code, and the > necessary code in the import machinery isn't implemented in 3.2 and earlier. > > Supporting unloading will be (and was) a multi-year project. Don't expect > any results in the next five years. > > ---------- > nosy: +loewis > resolution: -> wont fix > status: open -> closed > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue9072> > _______________________________________ > |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:02 | admin | set | github: 53318 |
| 2010年06月24日 23:34:49 | yappie | set | files:
+ unnamed messages: + msg108566 |
| 2010年06月24日 22:43:53 | loewis | set | status: open -> closed nosy: + loewis messages: + msg108558 resolution: wont fix |
| 2010年06月24日 19:32:47 | yappie | create | |