Message194040
> It appears that a few (1-3) module dicts are not being purged because they
> have been "orphaned". (i.e. the module object was garbaged collected before
> we check the weakref, but the module dict survived.)
Module globals can be kept alive by any function defined in that module. So if that function is registered eternally in a C static variable, the globals dict will never get collected.
> ./python -v -Xshowrefcount check_purging.py
I always get either:
# remaining {'encodings', '__main__'}
[...]
[24834 refs, 7249 blocks]
or
# remaining {'__main__', 'encodings'}
[...]
[24834 refs, 7249 blocks]
... which seems to hint that it is quite stable actually.
The encodings globals are kept alive because of the codecs registration, I believe.
As for the __main__ dict, perhaps we're missing a decref somewhere.
> Maybe 8 out of 50+ module dicts actually die a natural death by being
> garbage collected before they are purged.
I get different numbers from you. If I run "./python -v -c pass", most modules in the "wiping" phase are C extension modules, which is expected. Pretty much every pure Python module ends up garbage collected before that.
By the way, please also try issue18608 which will bring an other improvement. |
|
Date |
User |
Action |
Args |
2013-08-01 09:49:15 | pitrou | set | recipients:
+ pitrou, gregory.p.smith, amaury.forgeotdarc, Arfrever, python-dev, sbt |
2013-08-01 09:49:15 | pitrou | set | messageid: <1375350555.58.0.466500236393.issue18214@psf.upfronthosting.co.za> |
2013-08-01 09:49:15 | pitrou | link | issue18214 messages |
2013-08-01 09:49:15 | pitrou | create | |
|