Skip to content

Commit 7613272

Browse files
author
christian.heimes
committed
Deallocate content of the dict free list on interpreter shutdown
git-svn-id: http://svn.python.org/projects/python/trunk@60661 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 329d2ac commit 7613272

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

Include/pythonrun.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ PyAPI_FUNC(void) _PyImport_Fini(void);
130130
PyAPI_FUNC(void) PyMethod_Fini(void);
131131
PyAPI_FUNC(void) PyFrame_Fini(void);
132132
PyAPI_FUNC(void) PyCFunction_Fini(void);
133+
PyAPI_FUNC(void) PyDict_Fini(void);
133134
PyAPI_FUNC(void) PyTuple_Fini(void);
134135
PyAPI_FUNC(void) PyList_Fini(void);
135136
PyAPI_FUNC(void) PySet_Fini(void);

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
1212
Core and builtins
1313
-----------------
1414

15+
- Fixed a minor memory leak in dictobject.c. The content of the free
16+
list was not freed on interpreter shutdown.
17+
1518
- Limit free list of method and builtin function objects to 256 entries
1619
each.
1720

Objects/dictobject.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ show_alloc(void)
205205
static PyDictObject *free_list[PyDict_MAXFREELIST];
206206
static int numfree = 0;
207207

208+
void
209+
PyDict_Fini(void)
210+
{
211+
PyListObject *op;
212+
213+
while (numfree) {
214+
op = free_list[numfree--];
215+
assert(PyDict_CheckExact(op));
216+
PyObject_GC_Del(op);
217+
}
218+
}
219+
208220
PyObject *
209221
PyDict_New(void)
210222
{

Python/pythonrun.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ Py_Finalize(void)
473473
PyString_Fini();
474474
PyInt_Fini();
475475
PyFloat_Fini();
476+
PyDict_Fini();
476477

477478
#ifdef Py_USING_UNICODE
478479
/* Cleanup Unicode implementation */

0 commit comments

Comments
 (0)