Author pitrou
Recipients Arfrever, amaury.forgeotdarc, gregory.p.smith, pitrou, python-dev, sbt
Date 2013-08-01.09:49:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1375350555.58.0.466500236393.issue18214@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2013-08-01 09:49:15pitrousetrecipients: + pitrou, gregory.p.smith, amaury.forgeotdarc, Arfrever, python-dev, sbt
2013-08-01 09:49:15pitrousetmessageid: <1375350555.58.0.466500236393.issue18214@psf.upfronthosting.co.za>
2013-08-01 09:49:15pitroulinkissue18214 messages
2013-08-01 09:49:15pitroucreate