diff Python/pythonrun.c @ 37831:d82dced6f1fa legacy-trunk

Remove types from type_list if they have no objects and unlist_types_without_objects is set. Give dump_counts a FILE* argument.
author Martin v. Löwis <martin@v.loewis.de>
date Tue, 18 Apr 2006 06:24:08 +0000
parents 2f3f2e32dfd9
children 35f27bbd9ad8
line wrap: on
line diff
--- a/Python/pythonrun.c	Tue Apr 18 04:53:28 2006 +0000
+++ b/Python/pythonrun.c	Tue Apr 18 06:24:08 2006 +0000
@@ -311,7 +311,7 @@
 
 
 #ifdef COUNT_ALLOCS
-extern void dump_counts(void);
+extern void dump_counts(FILE*);
 #endif
 
 /* Undo the effect of Py_Initialize().
@@ -373,6 +373,13 @@
 	 * XXX I haven't seen a real-life report of either of these.
 	 */
 	PyGC_Collect();
+#ifdef COUNT_ALLOCS
+	/* With COUNT_ALLOCS, it helps to run GC multiple times:
+	   each collection might release some types from the type
+	   list, so they become garbage. */
+	while (PyGC_Collect() > 0)
+		/* nothing */;
+#endif
 
 	/* Destroy all modules */
 	PyImport_Cleanup();
@@ -401,7 +408,7 @@
 
 	/* Debugging stuff */
 #ifdef COUNT_ALLOCS
-	dump_counts();
+	dump_counts(stdout);
 #endif
 
 	PRINT_TOTAL_REFS();