diff options
author | Christian Heimes <christian@cheimes.de> | 2008-02-08 00:11:31 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-02-08 00:11:31 (GMT) |
commit | f75dbef208673865b31d32d5a2196b15b1b03024 (patch) | |
tree | 45cbf29ffd048f33fa21b1aae333d50209b7a6ea | |
parent | 83525859092e4bc2605503dc02abc8e27f2820b0 (diff) | |
download | cpython-f75dbef208673865b31d32d5a2196b15b1b03024.zip cpython-f75dbef208673865b31d32d5a2196b15b1b03024.tar.gz cpython-f75dbef208673865b31d32d5a2196b15b1b03024.tar.bz2 |
Deallocate content of the dict free list on interpreter shutdown
-rw-r--r-- | Include/pythonrun.h | 1 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Objects/dictobject.c | 12 | ||||
-rw-r--r-- | Python/pythonrun.c | 1 |
4 files changed, 17 insertions, 0 deletions
diff --git a/Include/pythonrun.h b/Include/pythonrun.h index cfc40e3..0164088 100644 --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -130,6 +130,7 @@ PyAPI_FUNC(void) _PyImport_Fini(void); PyAPI_FUNC(void) PyMethod_Fini(void); PyAPI_FUNC(void) PyFrame_Fini(void); PyAPI_FUNC(void) PyCFunction_Fini(void); +PyAPI_FUNC(void) PyDict_Fini(void); PyAPI_FUNC(void) PyTuple_Fini(void); PyAPI_FUNC(void) PyList_Fini(void); PyAPI_FUNC(void) PySet_Fini(void); @@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1? Core and builtins ----------------- +- Fixed a minor memory leak in dictobject.c. The content of the free + list was not freed on interpreter shutdown. + - Limit free list of method and builtin function objects to 256 entries each. diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 82d247f..9e2b944 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -205,6 +205,18 @@ show_alloc(void) static PyDictObject *free_list[PyDict_MAXFREELIST]; static int numfree = 0; +void +PyDict_Fini(void) +{ + PyListObject *op; + + while (numfree) { + op = free_list[numfree--]; + assert(PyDict_CheckExact(op)); + PyObject_GC_Del(op); + } +} + PyObject * PyDict_New(void) { diff --git a/Python/pythonrun.c b/Python/pythonrun.c index f5465c5..ec31af1 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -473,6 +473,7 @@ Py_Finalize(void) PyString_Fini(); PyInt_Fini(); PyFloat_Fini(); + PyDict_Fini(); #ifdef Py_USING_UNICODE /* Cleanup Unicode implementation */ |