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.

Author iritkatriel
Recipients Mark.Shannon, chris.jerdonek, corona10, gvanrossum, iritkatriel, lukasz.langa, miss-islington, pablogsal, vstinner
Date 2021-08-31.23:02:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1630450937.02.0.992459533297.issue44895@roundup.psfhosted.org>
In-reply-to
Content
Oh, I see now what you meant. 

I think you're right that it's cleanup. I changed dash_R_cleanup to put the sys._clear_type_cache() after clear_caches() and the leak is gone:

@@ -166,9 +166,6 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
         zipimport._zip_directory_cache.clear()
         zipimport._zip_directory_cache.update(zdc)
 
-    # clear type cache
-    sys._clear_type_cache()
-
     # Clear ABC registries, restoring previously saved ABC registries.
     abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
     abs_classes = filter(isabstract, abs_classes)
@@ -181,6 +178,12 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
 
     clear_caches()
 
+    # clear type cache
+    sys._clear_type_cache()
+
+    support.gc_collect()
+



I did this because I suspected it's something related to types, because it only happen when we define the exception classes (A and B) inside the test function. 

So maybe the type objects of these exceptions are not cleared from the type cache because they have refcount > 0 but by the time      clear_caches() and gc.collect() finish they are cleared?


Note this doesn't mean the change I made is always right - maybe the whole body of dash_R_cleanup should be in a loop until nothing changes?
History
Date User Action Args
2021-08-31 23:02:17iritkatrielsetrecipients: + iritkatriel, gvanrossum, vstinner, chris.jerdonek, lukasz.langa, Mark.Shannon, corona10, pablogsal, miss-islington
2021-08-31 23:02:17iritkatrielsetmessageid: <1630450937.02.0.992459533297.issue44895@roundup.psfhosted.org>
2021-08-31 23:02:17iritkatriellinkissue44895 messages
2021-08-31 23:02:16iritkatrielcreate