Skip to content

Commit 7d0d31a

Browse files
committed
Fix memory problems again
1 parent cda7fea commit 7d0d31a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/freetypy.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,19 @@ PyObject *freetypy_module;
8080
static void
8181
freetypy_module_dealloc(PyObject *m)
8282
{
83-
FT_Done_FreeType(ft_library);
83+
/*
84+
This doesn't always work because sometimes this module is
85+
freed before all of the Face objects have been destroyed.
86+
FT_Done_FreeType will try to free all open FT_Faces, and
87+
then the Py_Face destructors will try to free those again.
88+
In matplotlib, the old freetype wrapper never called
89+
FT_Done_FreeType (and even worse, there was no way to do
90+
that from Python 2.x) and it was never a real problem. So
91+
the easiest way to fix this is to just not call this and
92+
let the OS clean up on process ending, and let Python free
93+
the Face objects as it is done with them.
94+
*/
95+
// FT_Done_FreeType(ft_library);
8496
}
8597

8698
static struct PyModuleDef moduledef = {

0 commit comments

Comments
 (0)