diff options
author | Ken Hughes <khughes@pacific.edu> | 2005-11-30 11:18:06 +0300 |
---|---|---|
committer | Ken Hughes <khughes@pacific.edu> | 2005-11-30 11:18:06 +0300 |
commit | b7a4a6c8374e808837e45829ec85c48a409efd74 (patch) | |
tree | b6eb82e42fb0ff62bd60071267b4bf00afbb5a7f /source/blender/python/api2_2x/Draw.c | |
parent | 00f43109705ab7f251e4487143049205e27e38f1 (diff) |
-- Bugfix #3186: Fix memory leaks caused by multiple calls to
PyDict_SetItemString() with objects that were not properly decrefed
afterwards. Due to the number of places this was used, I added a
wrapper EXPP_dict_set_item_str() to gen_utils.c to handle it.
This started as a scriptlink bug, due to how many times scripts were
being executed I think it just magnified how bad the memory leak in
BPy was. Animating the blend attached with this bug report would cause
memory to grow by about 3MB for every 280 frames. After the patch,
memory did not appear to grow at all (or at least not noticably using
Unix's ps and top utils).
Since many of the PyDict_SetItemString() calls were in initialization
modules I think my tests executed most of the changed code, but would
appreciate script users really giving feedback.
Diffstat (limited to 'source/blender/python/api2_2x/Draw.c')
-rw-r--r-- | source/blender/python/api2_2x/Draw.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index e8c49dd71ff..57802c47746 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -534,12 +534,14 @@ void BPY_spacescript_do_pywin_event( SpaceScript * sc, unsigned short event, int pass_ascii = 0; if (ascii > 31 && ascii != 127) { pass_ascii = 1; - PyDict_SetItemString(g_blenderdict, "event", PyInt_FromLong((long)ascii)); + EXPP_dict_set_item_str(g_blenderdict, "event", + PyInt_FromLong((long)ascii)); } exec_callback( sc, sc->script->py_event, Py_BuildValue( "(ii)", event, val ) ); if (pass_ascii) - PyDict_SetItemString(g_blenderdict, "event", PyString_FromString("")); + EXPP_dict_set_item_str(g_blenderdict, "event", + PyString_FromString("")); } } @@ -1392,11 +1394,11 @@ PyObject *Draw_Init( void ) dict = PyModule_GetDict( submodule ); #define EXPP_ADDCONST(x) \ - PyDict_SetItemString(dict, #x, PyInt_FromLong(x)) + EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(x)) /* So, for example: * EXPP_ADDCONST(LEFTMOUSE) becomes - * PyDict_SetItemString(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE)) + * EXPP_dict_set_item_str(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE)) */ EXPP_ADDCONST( LEFTMOUSE ); |