mirror of
https://github.com/python/cpython.git
synced 2026-04-05 03:21:05 +00:00
Add more details when releasing interned strings
This commit is contained in:
parent
6fbb96e69a
commit
1c1a1c5aa1
1 changed files with 8 additions and 1 deletions
|
|
@ -4969,6 +4969,7 @@ void _Py_ReleaseInternedStrings(void)
|
|||
PyObject *keys;
|
||||
PyStringObject *s;
|
||||
Py_ssize_t i, n;
|
||||
Py_ssize_t immortal_size = 0, mortal_size = 0;
|
||||
|
||||
if (interned == NULL || !PyDict_Check(interned))
|
||||
return;
|
||||
|
|
@ -4983,8 +4984,9 @@ void _Py_ReleaseInternedStrings(void)
|
|||
give them their stolen references back, and then clear and DECREF
|
||||
the interned dict. */
|
||||
|
||||
fprintf(stderr, "releasing interned strings\n");
|
||||
n = PyList_GET_SIZE(keys);
|
||||
fprintf(stderr, "releasing %" PY_FORMAT_SIZE_T "d interned strings\n",
|
||||
n);
|
||||
for (i = 0; i < n; i++) {
|
||||
s = (PyStringObject *) PyList_GET_ITEM(keys, i);
|
||||
switch (s->ob_sstate) {
|
||||
|
|
@ -4993,15 +4995,20 @@ void _Py_ReleaseInternedStrings(void)
|
|||
break;
|
||||
case SSTATE_INTERNED_IMMORTAL:
|
||||
s->ob_refcnt += 1;
|
||||
immortal_size += s->ob_size;
|
||||
break;
|
||||
case SSTATE_INTERNED_MORTAL:
|
||||
s->ob_refcnt += 2;
|
||||
mortal_size += s->ob_size;
|
||||
break;
|
||||
default:
|
||||
Py_FatalError("Inconsistent interned string state.");
|
||||
}
|
||||
s->ob_sstate = SSTATE_NOT_INTERNED;
|
||||
}
|
||||
fprintf(stderr, "total size of all interned strings: "
|
||||
"%" PY_FORMAT_SIZE_T "d/%" PY_FORMAT_SIZE_T "d "
|
||||
"mortal/immortal\n", mortal_size, immortal_size);
|
||||
Py_DECREF(keys);
|
||||
PyDict_Clear(interned);
|
||||
Py_DECREF(interned);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue