From 436ec5b8e37ca2e5fc0f8d09a4c5f09cf406b4a5 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 14 Dec 2015 12:51:49 +0100 Subject: [PATCH] device: remove the unreferenced unreal devices When there's no connection that would use an unrealized device there's no more reason to keep the device in memory. It's in fact a resource leak. --- src/devices/nm-device.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 402b977ff7..9fb944c25d 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2068,6 +2068,11 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) remove_resources ? NM_DEVICE_STATE_REASON_USER_REQUESTED : NM_DEVICE_STATE_REASON_NOW_UNMANAGED); + /* Garbage-collect unneeded unrealized devices. */ + nm_device_recheck_available_connections (self); + if (g_hash_table_size (priv->available_connections) == 0) + g_signal_emit_by_name (self, NM_DEVICE_REMOVED); + return TRUE; }