I'm trying to call DBus
method of NetworkManager
by using Glib-Dbus
in linux
. When I create a GDBusProxy
by g_dbus_proxy_new_sync and then free it by g_object_unref, the new created GDBusProxy
seems not to be freed. I have used pmap -x <pid>
to display memory usage of my process and the RSS
value increased continuously. Can someone help me?
Here is the code that causes the problem:
int main (int argc, char *argv[])
{
GDBusConnection * connection = NULL;
GDBusProxy * proxy = NULL;
GError * error = NULL;
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM,
NULL,
&error);
g_assert_no_error(error);
error = NULL;
while (1)
{
proxy = g_dbus_proxy_new_sync(connection,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager/Settings",
"org.freedesktop .NetworkManager.Settings",
NULL,
NULL);
g_assert(proxy != NULL);
g_object_unref(proxy);
}
g_object_unref(connection);
return 0;
}
There is a patch attached to this bug report (which has been applied to the glib git repository) which should solve your problem: https://bugzilla.gnome.org/show_bug.cgi?id=758641
Presumably it will be in glib-2.46.3 and/or glib-2.48. It seems just to have been merged in the glib-2.46 branch.