[evolution-patches] memory leaks, calendar/addressbook, evo/eds




These patches address:
- major leaks in calendar (multi-megabytes)
- reduce memory usage in addressbook, for multiple local addressbooks (multi-megabytes)
- another 'minor' leak in calendar

These are the major leaks that seem to be present at this time in the codebase.


Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.256
diff -u -p -r1.256 ChangeLog
--- addressbook/ChangeLog	2 Mar 2005 02:58:13 -0000	1.256
+++ addressbook/ChangeLog	9 Mar 2005 10:27:15 -0000
@@ -1,3 +1,10 @@
+2005-03-09  Not Zed  <NotZed Ximian com>
+
+	* backends/file/e-book-backend-file.c
+	(e_book_backend_file_load_source): use a single global ref-counted
+	db-env for all opened db's.
+	(e_book_backend_file_dispose): clean up the env when finished.
+
 2005-03-01  Not Zed  <NotZed Ximian com>
 
 	** See bug #72878
Index: addressbook/backends/file/e-book-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/backends/file/e-book-backend-file.c,v
retrieving revision 1.29
diff -u -p -r1.29 e-book-backend-file.c
--- addressbook/backends/file/e-book-backend-file.c	6 Feb 2005 12:28:41 -0000	1.29
+++ addressbook/backends/file/e-book-backend-file.c	9 Mar 2005 10:27:16 -0000
@@ -71,6 +71,12 @@ struct _EBookBackendFilePrivate {
 	EBookBackendSummary *summary;
 };
 
+static GStaticMutex global_env_lock = G_STATIC_MUTEX_INIT;
+static struct {
+	int ref_count;
+	DB_ENV *env;
+} global_env;
+
 static void
 string_to_dbt(const char *str, DBT *dbt)
 {
@@ -1037,14 +1043,32 @@ e_book_backend_file_load_source (EBookBa
 		return GNOME_Evolution_Addressbook_OtherError;
 	}
 
-	db_error = db_env_create (&env, 0);
-	if (db_error != 0) {
-		g_warning ("db_env_create failed with %d", db_error);
-		return GNOME_Evolution_Addressbook_OtherError;
+	g_static_mutex_lock(&global_env_lock);
+	if (global_env.ref_count > 0) {
+		env = global_env.env;
+		global_env.ref_count++;
+	} else {
+		db_error = db_env_create (&env, 0);
+		if (db_error != 0) {
+			g_warning ("db_env_create failed with %d", db_error);
+			return GNOME_Evolution_Addressbook_OtherError;
+		}
+
+		db_error = env->open (env, NULL, DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_THREAD, 0);
+		if (db_error != 0) {
+			env->close(env, 0);
+			g_warning ("db_env_open failed with %d", db_error);
+			return GNOME_Evolution_Addressbook_OtherError;
+		}
+
+		env->set_errcall (env, file_errcall);
+
+		global_env.env = env;
+		global_env.ref_count = 1;
 	}
-	env->open (env, NULL, DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_THREAD, 0);
+	g_static_mutex_unlock(&global_env_lock);
 
-	env->set_errcall (env, file_errcall);
+	bf->priv->env = env;
 
 	db_error = db_create (&db, env, 0);
 	if (db_error != 0) {
@@ -1271,8 +1295,13 @@ e_book_backend_file_dispose (GObject *ob
 		if (bf->priv->file_db)
 			bf->priv->file_db->close (bf->priv->file_db, 0);
 
-		if (bf->priv->env)
-			bf->priv->env->close (bf->priv->env, 0);
+		g_static_mutex_lock(&global_env_lock);
+		global_env.ref_count--;
+		if (global_env.ref_count == 0) {
+			global_env.env->close(global_env.env, 0);
+			global_env.env = NULL;
+		}
+		g_static_mutex_unlock(&global_env_lock);
 
 		if (bf->priv->summary)
 			g_object_unref(bf->priv->summary);
Index: calendar/libical/ChangeLog
===================================================================
RCS file: /cvs/gnome/libical/ChangeLog,v
retrieving revision 1.169
diff -u -p -r1.169 ChangeLog
--- calendar/libical/ChangeLog	12 Jan 2005 08:45:34 -0000	1.169
+++ calendar/libical/ChangeLog	9 Mar 2005 10:27:16 -0000
@@ -1,3 +1,7 @@
+2005-03-09  Not Zed  <NotZed Ximian com>
+
+	* src/libical/icaltime.c (unset_tz): uncomment out free'ing code.
+
 2005-01-08  Not Zed  <NotZed Ximian com>
 
 	* src/libicalss/icalfileset.c (icalfileset_read_from_file)
Index: calendar/libical/src/libical/icaltime.c
===================================================================
RCS file: /cvs/gnome/libical/src/libical/icaltime.c,v
retrieving revision 1.34
diff -u -p -r1.34 icaltime.c
--- calendar/libical/src/libical/icaltime.c	22 Dec 2004 11:54:39 -0000	1.34
+++ calendar/libical/src/libical/icaltime.c	9 Mar 2005 10:27:17 -0000
@@ -347,8 +347,8 @@ void unset_tz(char *tzstr)
     } 
 
     /* Free any previous TZ environment string we have used. */
-    //if (saved_tz)
-    //  free (saved_tz);
+    if (saved_tz)
+	free (saved_tz);
 
     /* Save a pointer to the TZ string we just set, so we can free it later.
        (This can possibly be NULL if there was no TZ to restore.) */
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2680
diff -u -p -r1.2680 ChangeLog
--- calendar/ChangeLog	1 Mar 2005 01:14:56 -0000	1.2680
+++ calendar/ChangeLog	9 Mar 2005 10:23:32 -0000
@@ -1,3 +1,9 @@
+2005-03-09  Not Zed  <NotZed Ximian com>
+
+	* gui/e-week-view-event-item.c (e_week_view_event_item_draw_icons):
+	* gui/e-day-view.c (e_day_view_reshape_day_event): free the ecalcomponent
+	after using it.
+
 2005-02-28  Harish Krishnaswamy  <kharish novell com>
 
         Fixes #69556
Index: calendar/gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.268
diff -u -p -r1.268 e-day-view.c
--- calendar/gui/e-day-view.c	4 Feb 2005 11:22:52 -0000	1.268
+++ calendar/gui/e-day-view.c	9 Mar 2005 10:23:35 -0000
@@ -4475,6 +4475,7 @@ e_day_view_reshape_day_event (EDayView *
 					num_icons++;
 			}
 			e_cal_component_free_categories_list (categories_list);
+			g_object_unref(comp);
 		}
 
 		if (num_icons > 0) {
Index: calendar/gui/e-week-view-event-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view-event-item.c,v
retrieving revision 1.51
diff -u -p -r1.51 e-week-view-event-item.c
--- calendar/gui/e-week-view-event-item.c	8 Jan 2005 10:53:53 -0000	1.51
+++ calendar/gui/e-week-view-event-item.c	9 Mar 2005 10:23:35 -0000
@@ -721,6 +721,7 @@ e_week_view_event_item_draw_icons (EWeek
 	}
 
 	e_cal_component_free_categories_list (categories_list);
+	g_object_unref(comp);
 
 	gdk_gc_set_clip_mask (gc, NULL);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]