Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.

This commit is contained in:
Christian Heimes 2008-02-14 12:47:33 +00:00
parent 50361d4d9b
commit 3b718a79af
15 changed files with 131 additions and 25 deletions

View file

@ -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