diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-02-25 15:52:27 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-02-25 15:52:27 (GMT) |
commit | 1c1a1c5aa1d377a7354fdf050e3bf705ee8d5c41 (patch) | |
tree | d8c853be5811ba681f987f8d9316010e45c9e36f /Objects | |
parent | 6fbb96e69a047312a425caa7021dce31669b4076 (diff) | |
download | cpython-1c1a1c5aa1d377a7354fdf050e3bf705ee8d5c41.zip cpython-1c1a1c5aa1d377a7354fdf050e3bf705ee8d5c41.tar.gz cpython-1c1a1c5aa1d377a7354fdf050e3bf705ee8d5c41.tar.bz2 |
Add more details when releasing interned strings
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/stringobject.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 5d31c38..1f31805 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -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); |