Running NetworkManager through valgrind turned up a whole bunch of leaks, some of which I've managed to fix with the attached patch. There's still a fair amount of work to be done here, but part of the problem is current limitations in the Dbus and glib APIs for properly freeing no longer needed structures.

Tom
--
[EMAIL PROTECTED] - http://tevp.net
Illegitimus non carborundum
Index: src/NetworkManager.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManager.c,v
retrieving revision 1.67
diff -u -r1.67 NetworkManager.c
--- src/NetworkManager.c        6 Apr 2005 16:45:48 -0000       1.67
+++ src/NetworkManager.c        14 Apr 2005 11:12:17 -0000
@@ -526,6 +526,8 @@
        g_main_loop_unref (data->main_loop);
        g_main_context_unref (data->main_context);
 
+       g_io_channel_unref(data->sigterm_iochannel);
+
        memset (data, 0, sizeof (NMData));
 }
 
Index: src/NetworkManagerAPList.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerAPList.c,v
retrieving revision 1.36
diff -u -r1.36 NetworkManagerAPList.c
--- src/NetworkManagerAPList.c  6 Apr 2005 19:05:10 -0000       1.36
+++ src/NetworkManagerAPList.c  14 Apr 2005 11:12:17 -0000
@@ -116,6 +116,7 @@
                        nm_unlock_mutex (list->mutex, __FUNCTION__);
 
                g_mutex_free (list->mutex);
+               g_free(list);
        }
 }
 
Index: src/NetworkManagerDevice.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerDevice.c,v
retrieving revision 1.121
diff -u -r1.121 NetworkManagerDevice.c
--- src/NetworkManagerDevice.c  6 Apr 2005 19:16:31 -0000       1.121
+++ src/NetworkManagerDevice.c  14 Apr 2005 11:12:17 -0000
@@ -842,7 +842,8 @@
        if (g_file_get_contents (carrier_path, &contents, &length, NULL)) {
                link = (gboolean) atoi (contents);
                g_free (contents);
-       } 
+       }
+       g_free(carrier_path);
 
        /* We say that non-carrier-detect devices always have a link, because
         * they never get auto-selected by NM.  User has to force them on us,
Index: src/NetworkManagerUtils.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerUtils.c,v
retrieving revision 1.33
diff -u -r1.33 NetworkManagerUtils.c
--- src/NetworkManagerUtils.c   6 Apr 2005 16:45:48 -0000       1.33
+++ src/NetworkManagerUtils.c   14 Apr 2005 11:12:17 -0000
@@ -448,6 +448,7 @@
 
                if (parent_udi && libhal_device_property_exists (ctx, 
parent_udi, "info.linux.driver", NULL))
                        driver_name = libhal_device_get_property_string (ctx, 
parent_udi, "info.linux.driver", NULL);
+               g_free(parent_udi);
        }
 
        return (driver_name);
Index: src/nm-netlink-monitor.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-netlink-monitor.c,v
retrieving revision 1.4
diff -u -r1.4 nm-netlink-monitor.c
--- src/nm-netlink-monitor.c    17 Mar 2005 21:43:21 -0000      1.4
+++ src/nm-netlink-monitor.c    14 Apr 2005 11:12:17 -0000
@@ -569,7 +569,7 @@
                                  NmNetlinkMonitor *monitor)
 {
        GError *error;
-       gchar *received_bytes;
+       gchar *received_bytes=NULL;
        gboolean processing_is_done;
        gsize num_received_bytes;
        guint num_bytes_to_process;
@@ -711,6 +711,8 @@
                        g_free (interface_name);
                }
        }
+       if (received_bytes!=NULL)
+               g_free(received_bytes);
 
        return TRUE;
 }
_______________________________________________
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to