diff --git a/paddle/fluid/pybind/eager_utils.cc b/paddle/fluid/pybind/eager_utils.cc index 9bcac35037d0476b75315874fca366b7d8caacdd..cdbdb8c6424dde25e86a7fc05c3399f083f23f11 100644 --- a/paddle/fluid/pybind/eager_utils.cc +++ b/paddle/fluid/pybind/eager_utils.cc @@ -734,12 +734,15 @@ PyObject* ToPyObject( PADDLE_THROW( platform::errors::Fatal("Unable to append string to py_list")); } + Py_DECREF(val_string); } if (PyDict_SetItem(dict, key_string, py_list) != 0) { PADDLE_THROW( platform::errors::Fatal("Unable to set key:value for py_dict")); } + Py_DECREF(py_list); + Py_DECREF(key_string); } return dict;