[ https://issues.apache.org/jira/browse/THRIFT-5881?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kevin Rodgers updated THRIFT-5881: ---------------------------------- Description: In newer versions of glib the {{g_object_unref}} call has been updated to freeze the object’s notification queue. This causes memory to be allocated and saved in [object->qdata|https://github.com/GNOME/glib/blob/c1e8174992182d7a6e6499ea9ab2cf76ad81a3ca/gobject/gobject.c#L4828].This memory is freed when the notification queue is thawed, which usually happens in the \{class}_finalize method call of the object’s parent class. In the thrift generated finalize method there is no call to finalize the parent object and the memory that has been allocated to freeze notifications is lost. This causes the process size to increase as objects are created and destroyed. I have fixed this in my environment by updating [t_c_glib_generator.cc|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc#L3306]{color:#172b4d} to call g_datalist_clear{color} at the very end of each \{class}_finalize method. {quote}static void test_object_finalize (GObject *object) { TestObject *tobject = TEST_OBJECT (object); /* satisfy -Wall in case we don't use tobject */ THRIFT_UNUSED_VAR (tobject); if (tobject->versions != NULL) { g_free(tobject->versions); tobject->versions = NULL; } g_datalist_clear(&object->qdata); // thaw queue, free memory } {quote} was: In newer versions of glib the {{g_object_unref}} call has been updated to freeze the object’s notification queue. This causes memory to be allocated and saved in [object->qdata|https://github.com/GNOME/glib/blob/c1e8174992182d7a6e6499ea9ab2cf76ad81a3ca/gobject/gobject.c#L4828].This memory is freed when the notification queue is thawed, which usually happens in the \{class}_finalize method call of the object’s parent class. In the thrift generated finalize method there is no call to finalize the parent object and the memory that has been allocated to freeze notifications is lost. This causes the process size to increase as objects are created and destroyed. I have fixed this in my environment by updating [t_c_glib_generator.cc|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc#L3306]{color:#172b4d} to call g_datalist_clear{color} at the very end of each \{class}_finalize method. > [Glib] The {class}_finalize method created by c_glib generator is leaking > memory > -------------------------------------------------------------------------------- > > Key: THRIFT-5881 > URL: https://issues.apache.org/jira/browse/THRIFT-5881 > Project: Thrift > Issue Type: Bug > Components: C glib - Compiler > Reporter: Kevin Rodgers > Priority: Major > > In newer versions of glib the {{g_object_unref}} call has been updated to > freeze the object’s notification queue. This causes memory to be allocated > and saved in > [object->qdata|https://github.com/GNOME/glib/blob/c1e8174992182d7a6e6499ea9ab2cf76ad81a3ca/gobject/gobject.c#L4828].This > memory is freed when the notification queue is thawed, which usually happens > in the \{class}_finalize method call of the object’s parent class. > In the thrift generated finalize method there is no call to finalize the > parent object and the memory that has been allocated to freeze notifications > is lost. This causes the process size to increase as objects are created and > destroyed. I have fixed this in my environment by updating > [t_c_glib_generator.cc|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc#L3306]{color:#172b4d} > to call g_datalist_clear{color} at the very end of each \{class}_finalize > method. > {quote}static void > test_object_finalize (GObject *object) > { > TestObject *tobject = TEST_OBJECT (object); > /* satisfy -Wall in case we don't use tobject */ > THRIFT_UNUSED_VAR (tobject); > if (tobject->versions != NULL) > { > g_free(tobject->versions); > tobject->versions = NULL; > } > g_datalist_clear(&object->qdata); // thaw queue, free memory > } > {quote} -- This message was sent by Atlassian Jira (v8.20.10#820010)