mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
This commit is contained in:
		
							parent
							
								
									50361d4d9b
								
							
						
					
					
						commit
						3b718a79af
					
				
					 15 changed files with 131 additions and 25 deletions
				
			
		|  | @ -8853,10 +8853,29 @@ void _PyUnicode_Init(void) | |||
| 
 | ||||
| /* Finalize the Unicode implementation */ | ||||
| 
 | ||||
| int | ||||
| PyUnicode_ClearFreeList(void) | ||||
| { | ||||
|     int freelist_size = numfree; | ||||
|     PyUnicodeObject *u; | ||||
| 
 | ||||
|     for (u = free_list; u != NULL;) { | ||||
| 	PyUnicodeObject *v = u; | ||||
| 	u = *(PyUnicodeObject **)u; | ||||
| 	if (v->str) | ||||
| 	    PyMem_DEL(v->str); | ||||
| 	Py_XDECREF(v->defenc); | ||||
| 	PyObject_Del(v); | ||||
| 	numfree--; | ||||
|     } | ||||
|     free_list = NULL; | ||||
|     assert(numfree == 0); | ||||
|     return freelist_size; | ||||
| } | ||||
| 
 | ||||
| void | ||||
| _PyUnicode_Fini(void) | ||||
| { | ||||
|     PyUnicodeObject *u; | ||||
|     int i; | ||||
| 
 | ||||
|     Py_XDECREF(unicode_empty); | ||||
|  | @ -8868,17 +8887,7 @@ _PyUnicode_Fini(void) | |||
| 	    unicode_latin1[i] = NULL; | ||||
| 	} | ||||
|     } | ||||
| 
 | ||||
|     for (u = free_list; u != NULL;) { | ||||
| 	PyUnicodeObject *v = u; | ||||
| 	u = *(PyUnicodeObject **)u; | ||||
| 	if (v->str) | ||||
| 	    PyMem_DEL(v->str); | ||||
| 	Py_XDECREF(v->defenc); | ||||
| 	PyObject_Del(v); | ||||
|     } | ||||
|     free_list = NULL; | ||||
|     numfree = 0; | ||||
|     (void)PyUnicode_ClearFreeList(); | ||||
| } | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Christian Heimes
						Christian Heimes