[evolution-patches] Memory leaks all over
- From: Hans Petter Jansson <hpj ximian com>
- To: evolution-patches ximian com
- Subject: [evolution-patches] Memory leaks all over
- Date: 14 Apr 2003 22:16:26 -0500
I went and fixed the biggest and most low-hanging memory leaks I could
find. Here are patches for calendar, mail, shell, GAL, and misc (e-util
and widgets). Please review. I'll write ChangeLogs and commit with
approval.
Some of the leaks are quite big. I believe our savings will be in the
hundreds of kilobytes (from a 5-minute sample run). Also note that there
are still a few leaks around, and I didn't do an exhaustive search.
--
Hans Petter
? evolution-trunk-calendar-leaks.patch
Index: gui/calendar-component.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-component.c,v
retrieving revision 1.78
diff -u -p -r1.78 calendar-component.c
--- gui/calendar-component.c 14 Mar 2003 19:42:28 -0000 1.78
+++ gui/calendar-component.c 15 Apr 2003 03:11:10 -0000
@@ -60,7 +60,7 @@
#define CREATE_MEETING_ID "meeting"
#define CREATE_TASK_ID "task"
-char *evolution_dir;
+char *evolution_dir = NULL;
EvolutionShellClient *global_shell_client = NULL;
extern ECompEditorRegistry *comp_editor_registry;
@@ -506,6 +506,8 @@ owner_set_cb (EvolutionShellComponent *s
const char *evolution_homedir,
gpointer user_data)
{
+ if (evolution_dir)
+ g_free (evolution_dir);
evolution_dir = g_strdup (evolution_homedir);
global_shell_client = shell_client;
}
Index: gui/e-day-view-time-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-time-item.c,v
retrieving revision 1.25
diff -u -p -r1.25 e-day-view-time-item.c
--- gui/e-day-view-time-item.c 2 Apr 2003 03:08:28 -0000 1.25
+++ gui/e-day-view-time-item.c 15 Apr 2003 03:11:10 -0000
@@ -436,6 +436,9 @@ e_day_view_time_item_draw (GnomeCanvasIt
e_day_view_time_item_increment_time (&hour, &minute,
day_view->mins_per_row);
}
+
+ pango_font_metrics_unref (large_font_metrics);
+ pango_font_metrics_unref (small_font_metrics);
}
Index: gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.184
diff -u -p -r1.184 e-day-view.c
--- gui/e-day-view.c 2 Apr 2003 03:08:29 -0000 1.184
+++ gui/e-day-view.c 15 Apr 2003 03:11:13 -0000
@@ -1261,6 +1261,7 @@ e_day_view_style_set (GtkWidget *widget,
gtk_widget_set_usize (day_view->time_canvas, times_width, -1);
g_object_unref (layout);
+ pango_font_metrics_unref (font_metrics);
}
@@ -1327,7 +1328,6 @@ e_day_view_recalc_cell_sizes (EDayView *
char buffer[128];
PangoFontDescription *font_desc;
PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
PangoLayout *layout;
gint pango_width;
@@ -1336,8 +1336,6 @@ e_day_view_recalc_cell_sizes (EDayView *
/* Set up Pango prerequisites */
font_desc = gtk_widget_get_style (GTK_WIDGET (day_view))->font_desc;
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
- font_metrics = pango_context_get_metrics (pango_context, font_desc,
- pango_context_get_language (pango_context));
layout = pango_layout_new (pango_context);
/* Calculate the column sizes, using floating point so that pixels
@@ -5192,7 +5190,6 @@ e_day_view_reshape_long_event (EDayView
gboolean show_icons = TRUE, use_max_width = FALSE;
PangoFontDescription *font_desc;
PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
PangoLayout *layout;
event = &g_array_index (day_view->long_events, EDayViewEvent,
@@ -5223,8 +5220,6 @@ e_day_view_reshape_long_event (EDayView
/* Set up Pango prerequisites */
font_desc = gtk_widget_get_style (GTK_WIDGET (day_view))->font_desc;
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
- font_metrics = pango_context_get_metrics (pango_context, font_desc,
- pango_context_get_language (pango_context));
layout = pango_layout_new (pango_context);
if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE
Index: gui/e-meeting-model.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-meeting-model.c,v
retrieving revision 1.46
diff -u -p -r1.46 e-meeting-model.c
--- gui/e-meeting-model.c 11 Apr 2003 09:15:22 -0000 1.46
+++ gui/e-meeting-model.c 15 Apr 2003 03:11:14 -0000
@@ -657,7 +657,7 @@ init (EMeetingModel *im)
free_gotten_key,
free_duplicated_key,
NULL));
- e_table_without_hide (priv->without, g_strdup ("delegator"));
+ e_table_without_hide (priv->without, "delegator");
/* FIXME We basically sink a ref otherwise the without table
* will own a ref to us and we will never get finalized */
Index: gui/e-meeting-time-sel.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-meeting-time-sel.c,v
retrieving revision 1.44
diff -u -p -r1.44 e-meeting-time-sel.c
--- gui/e-meeting-time-sel.c 10 Apr 2003 21:54:04 -0000 1.44
+++ gui/e-meeting-time-sel.c 15 Apr 2003 03:11:15 -0000
@@ -958,6 +958,7 @@ e_meeting_time_selector_style_set (GtkWi
GTK_LAYOUT (mts->display_main)->vadjustment->step_increment = mts->row_height;
g_object_unref (layout);
+ pango_font_metrics_unref (font_metrics);
}
/* This draws a shadow around the top display and main display. */
@@ -2059,14 +2060,11 @@ e_meeting_time_selector_recalc_date_form
gchar buffer[128];
PangoFontDescription *font_desc;
PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
PangoLayout *layout;
/* Set up Pango prerequisites */
font_desc = gtk_widget_get_style (GTK_WIDGET (mts))->font_desc;
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (mts));
- font_metrics = pango_context_get_metrics (pango_context, font_desc,
- pango_context_get_language (pango_context));
layout = pango_layout_new (pango_context);
/* Calculate the maximum date width we can fit into the display. */
Index: gui/e-week-view-main-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view-main-item.c,v
retrieving revision 1.15
diff -u -p -r1.15 e-week-view-main-item.c
--- gui/e-week-view-main-item.c 7 Apr 2003 00:14:52 -0000 1.15
+++ gui/e-week-view-main-item.c 15 Apr 2003 03:11:15 -0000
@@ -377,6 +377,8 @@ e_week_view_main_item_draw_day (EWeekVie
x + E_WEEK_VIEW_DATE_LINE_L_PAD, line_y,
right_edge, line_y);
}
+
+ pango_font_metrics_unref (font_metrics);
}
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.155
diff -u -p -r1.155 e-week-view.c
--- gui/e-week-view.c 7 Apr 2003 00:14:52 -0000 1.155
+++ gui/e-week-view.c 15 Apr 2003 03:11:17 -0000
@@ -757,6 +757,7 @@ e_week_view_style_set (GtkWidget *widget
week_view->pm_string);
g_object_unref (layout);
+ pango_font_metrics_unref (font_metrics);
}
@@ -917,6 +918,8 @@ e_week_view_recalc_cell_sizes (EWeekView
else if (width / 2 > time_width)
week_view->time_format = E_WEEK_VIEW_TIME_START;
}
+
+ pango_font_metrics_unref (font_metrics);
}
@@ -2665,13 +2668,6 @@ e_week_view_reshape_event_span (EWeekVie
one_day_event = e_week_view_is_one_day_event (week_view, event_num);
- /* Set up Pango prerequisites */
- font_desc = gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc;
- pango_context = gtk_widget_get_pango_context (GTK_WIDGET (week_view));
- font_metrics = pango_context_get_metrics (pango_context, font_desc,
- pango_context_get_language (pango_context));
- layout = pango_layout_new (pango_context);
-
/* If the span will not be visible destroy the canvas items and
return. */
if (!e_week_view_get_span_position (week_view, event_num, span_num,
@@ -2685,6 +2681,13 @@ e_week_view_reshape_event_span (EWeekVie
return;
}
+ /* Set up Pango prerequisites */
+ font_desc = gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc;
+ pango_context = gtk_widget_get_pango_context (GTK_WIDGET (week_view));
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
+
/* If we are editing a long event we don't show the icons and the EText
item uses the maximum width available. */
if (!one_day_event && week_view->editing_event_num == event_num
@@ -2889,6 +2892,7 @@ e_week_view_reshape_event_span (EWeekVie
e_canvas_item_move_absolute (span->text_item, text_x, text_y);
g_object_unref (layout);
+ pango_font_metrics_unref (font_metrics);
}
Index: gui/weekday-picker.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/weekday-picker.c,v
retrieving revision 1.15
diff -u -p -r1.15 weekday-picker.c
--- gui/weekday-picker.c 2 Apr 2003 03:08:29 -0000 1.15
+++ gui/weekday-picker.c 15 Apr 2003 03:11:18 -0000
@@ -402,6 +402,7 @@ weekday_picker_style_set (GtkWidget *wid
configure_items (wp);
g_object_unref (layout);
+ pango_font_metrics_unref (font_metrics);
if (GTK_WIDGET_CLASS (parent_class)->style_set)
(* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous_style);
Index: gui/dialogs/meeting-page.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/meeting-page.c,v
retrieving revision 1.64
diff -u -p -r1.64 meeting-page.c
--- gui/dialogs/meeting-page.c 11 Apr 2003 10:41:37 -0000 1.64
+++ gui/dialogs/meeting-page.c 15 Apr 2003 03:11:18 -0000
@@ -278,6 +278,11 @@ meeting_page_finalize (GObject *object)
priv->xml = NULL;
}
+ if (priv->default_address) {
+ g_free (priv->default_address);
+ priv->default_address = NULL;
+ }
+
g_free (priv);
mpage->priv = NULL;
? evolution-trunk-mail-leaks.patch
Index: mail-mt.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-mt.c,v
retrieving revision 1.67
diff -u -p -r1.67 mail-mt.c
--- mail-mt.c 10 Feb 2003 19:50:55 -0000 1.67
+++ mail-mt.c 15 Apr 2003 03:10:43 -0000
@@ -273,6 +273,7 @@ void mail_msg_check_error(void *msg)
g_signal_connect(gd, "response", G_CALLBACK(error_response), m->ops);
g_signal_connect(gd, "destroy", G_CALLBACK(error_destroy), m->ops);
gtk_widget_show((GtkWidget *)gd);
+ g_free (text);
}
void mail_msg_cancel(unsigned int msgid)
? widgets/misc/log
Index: e-util/e-sexp.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-sexp.c,v
retrieving revision 1.31
diff -u -p -r1.31 e-sexp.c
--- e-util/e-sexp.c 19 Mar 2003 19:49:44 -0000 1.31
+++ e-util/e-sexp.c 15 Apr 2003 03:12:56 -0000
@@ -1181,6 +1181,8 @@ e_sexp_add_function(ESExp *f, int scope,
g_return_if_fail (IS_E_SEXP (f));
g_return_if_fail (name != NULL);
+ e_sexp_remove_symbol (f, scope, name);
+
s = g_malloc0(sizeof(*s));
s->name = g_strdup(name);
s->f.func = func;
@@ -1196,6 +1198,8 @@ e_sexp_add_ifunction(ESExp *f, int scope
g_return_if_fail (IS_E_SEXP (f));
g_return_if_fail (name != NULL);
+
+ e_sexp_remove_symbol (f, scope, name);
s = g_malloc0(sizeof(*s));
s->name = g_strdup(name);
Index: widgets/misc/e-calendar-item.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-calendar-item.c,v
retrieving revision 1.32
diff -u -p -r1.32 e-calendar-item.c
--- widgets/misc/e-calendar-item.c 3 Apr 2003 04:00:19 -0000 1.32
+++ widgets/misc/e-calendar-item.c 15 Apr 2003 03:12:57 -0000
@@ -891,6 +891,8 @@ e_calendar_item_update (GnomeCanvasItem
gnome_canvas_request_redraw (item->canvas, item->x1, item->y1,
item->x2, item->y2);
+
+ pango_font_metrics_unref (font_metrics);
}
@@ -926,7 +928,7 @@ e_calendar_item_draw (GnomeCanvasItem *
font_desc = calitem->font_desc;
if (!font_desc)
font_desc = style->font_desc;
- pango_context = gtk_widget_create_pango_context (GTK_WIDGET (canvas_item->canvas));
+ pango_context = gtk_widget_get_pango_context (GTK_WIDGET (canvas_item->canvas));
font_metrics = pango_context_get_metrics (pango_context, font_desc,
pango_context_get_language (pango_context));
@@ -993,6 +995,8 @@ e_calendar_item_draw (GnomeCanvasItem *
row_y += calitem->month_height;
}
+
+ pango_font_metrics_unref (font_metrics);
}
@@ -1046,7 +1050,8 @@ e_calendar_item_draw_month (ECalendarIte
xthickness = style->xthickness;
ythickness = style->ythickness;
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
- layout = gtk_widget_create_pango_layout (widget, NULL);
+
+ pango_font_metrics_unref (font_metrics);
/* Calculate the top-left position of the entire month display. */
month_x = item->x1 + xthickness + calitem->x_offset
@@ -1068,6 +1073,9 @@ e_calendar_item_draw_month (ECalendarIte
/* Draw the month name & year, with clipping. Note that the top row
needs extra space around it for the buttons. */
+
+ layout = gtk_widget_create_pango_layout (widget, NULL);
+
if (row == 0 && col == 0)
min_x = E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME_WITH_BUTTON;
else
@@ -1122,8 +1130,10 @@ e_calendar_item_draw_month (ECalendarIte
clip_width = month_x + month_w - clip_rect.x;
clip_height = month_y + month_h - clip_rect.y;
- if (clip_width <= 0 || clip_height <= 0)
+ if (clip_width <= 0 || clip_height <= 0) {
+ g_object_unref (layout);
return;
+ }
clip_rect.width = clip_width;
clip_rect.height = clip_height;
@@ -1492,6 +1502,7 @@ e_calendar_item_draw_day_numbers (ECalen
gdk_gc_set_foreground (fg_gc, &style->fg[GTK_STATE_NORMAL]);
g_object_unref (layout);
+ pango_font_metrics_unref (font_metrics);
}
@@ -1668,6 +1679,7 @@ e_calendar_item_recalc_sizes (ECalendar
g_object_unref (layout);
g_object_unref (pango_context);
+ pango_font_metrics_unref (font_metrics);
}
@@ -2056,6 +2068,8 @@ e_calendar_item_convert_position_to_day
PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
xthickness = style->xthickness;
ythickness = style->ythickness;
+
+ pango_font_metrics_unref (font_metrics);
*entire_week = FALSE;
Index: widgets/misc/e-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-calendar.c,v
retrieving revision 1.19
diff -u -p -r1.19 e-calendar.c
--- widgets/misc/e-calendar.c 2 Apr 2003 05:38:19 -0000 1.19
+++ widgets/misc/e-calendar.c 15 Apr 2003 03:12:57 -0000
@@ -358,6 +358,8 @@ e_calendar_size_allocate (GtkWidget *wid
"width", arrow_button_size,
"height", arrow_button_size,
NULL);
+
+ pango_font_metrics_unref (font_metrics);
}
void
? evolution-trunk-shell-leaks.patch
Index: e-setup.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-setup.c,v
retrieving revision 1.38
diff -u -p -r1.38 e-setup.c
--- e-setup.c 8 Apr 2003 16:05:35 -0000 1.38
+++ e-setup.c 15 Apr 2003 03:10:17 -0000
@@ -303,11 +303,18 @@ e_setup_check_config (const char *evolut
{
GConfClient *client;
char *tmp;
+ gboolean present = FALSE;
client = gconf_client_get_default ();
tmp = gconf_client_get_string (client, "/apps/evolution/shell/default_folders/mail_uri", NULL);
- if (tmp != NULL && *tmp != 0) {
+ if (tmp != NULL) {
+ if (*tmp != 0)
+ present = TRUE;
+ g_free (tmp);
+ }
+
+ if (present) {
g_object_unref (client);
return;
}
Index: e-shell-user-creatable-items-handler.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell-user-creatable-items-handler.c,v
retrieving revision 1.26
diff -u -p -r1.26 e-shell-user-creatable-items-handler.c
--- e-shell-user-creatable-items-handler.c 27 Jan 2003 16:57:17 -0000 1.26
+++ e-shell-user-creatable-items-handler.c 15 Apr 2003 03:10:18 -0000
@@ -307,9 +307,13 @@ append_xml_for_menu_item (GString *xml,
else if (item->shortcut != '\0')
g_string_append_printf (xml, " accel=\"*Control**Shift*%c\"", item->shortcut);
- if (item->icon != NULL)
- g_string_append_printf (xml, " pixtype=\"pixbuf\" pixname=\"%s\"",
- bonobo_ui_util_pixbuf_to_xml (item->icon));
+ if (item->icon != NULL) {
+ char *icon_xml;
+
+ icon_xml = bonobo_ui_util_pixbuf_to_xml (item->icon);
+ g_string_append_printf (xml, " pixtype=\"pixbuf\" pixname=\"%s\"", icon_xml);
+ g_free (icon_xml);
+ }
encoded_tooltip = bonobo_ui_util_encode_str (item->tooltip);
g_string_append_printf (xml, " tip=\"%s\"", encoded_tooltip);
Index: e-shell.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell.c,v
retrieving revision 1.212
diff -u -p -r1.212 e-shell.c
--- e-shell.c 7 Apr 2003 20:19:59 -0000 1.212
+++ e-shell.c 15 Apr 2003 03:10:19 -0000
@@ -2152,7 +2152,7 @@ parse_default_uri (EShell *shell,
{
GConfClient *client;
const char *component_start;
- const char *component;
+ char *component;
const char *p;
char *config_path;
char *path;
@@ -2170,6 +2170,8 @@ parse_default_uri (EShell *shell,
config_path = g_strdup_printf ("/apps/evolution/shell/default_folders/%s_path", component);
path = gconf_client_get_string (client, config_path, NULL);
g_object_unref (client);
+ g_free (component);
+ g_free (config_path);
/* We expect an evolution: URI here, if we don't get it then something
is messed up. */
@@ -2192,6 +2194,7 @@ parse_default_uri (EShell *shell,
*extra_return = g_strdup (p + 1);
}
+ g_free (path);
return TRUE;
}
Index: e-storage.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-storage.c,v
retrieving revision 1.55
diff -u -p -r1.55 e-storage.c
--- e-storage.c 14 Mar 2003 19:58:36 -0000 1.55
+++ e-storage.c 15 Apr 2003 03:10:19 -0000
@@ -735,6 +735,7 @@ e_storage_declare_has_subfolders (EStora
GList *subfolders, *f;
EFolder *pseudofolder;
char *pseudofolder_path;
+ gboolean result;
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
@@ -764,7 +765,9 @@ e_storage_declare_has_subfolders (EStora
g_hash_table_insert (priv->pseudofolders, g_strdup (path), pseudofolder);
- return e_storage_new_folder (storage, pseudofolder_path, pseudofolder);
+ result = e_storage_new_folder (storage, pseudofolder_path, pseudofolder);
+ g_free (pseudofolder_path);
+ return result;
}
gboolean
? log
? docs/gal-api.html
Index: gal/e-table/e-table-header-utils.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table-header-utils.c,v
retrieving revision 1.14
diff -u -p -r1.14 e-table-header-utils.c
--- gal/e-table/e-table-header-utils.c 13 Feb 2003 16:07:38 -0000 1.14
+++ gal/e-table/e-table-header-utils.c 15 Apr 2003 03:04:21 -0000
@@ -308,8 +308,6 @@ e_table_draw_elided_string (GdkDrawable
y + height / 2 + i + 1);
}
}
-
- g_object_unref (layout);
}
static GtkWidget *g_label;
@@ -478,4 +476,6 @@ e_table_header_draw_button (GdkDrawable
inner_x, inner_y,
layout, ecol->text, inner_width, TRUE);
}
+
+ g_object_unref (layout);
}
Index: gal/e-table/e-tree-table-adapter.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-tree-table-adapter.c,v
retrieving revision 1.51
diff -u -p -r1.51 e-tree-table-adapter.c
--- gal/e-table/e-tree-table-adapter.c 4 Apr 2003 16:16:35 -0000 1.51
+++ gal/e-table/e-tree-table-adapter.c 15 Apr 2003 03:04:21 -0000
@@ -983,6 +983,8 @@ e_tree_table_adapter_load_expanded_state
path = e_tree_model_get_node_by_id(etta->priv->source, id);
if (path)
e_tree_table_adapter_node_set_expanded(etta, path, !model_default);
+
+ g_free (id);
}
xmlFreeDoc (doc);
Index: gal/menus/gal-view-instance.c
===================================================================
RCS file: /cvs/gnome/gal/gal/menus/gal-view-instance.c,v
retrieving revision 1.12
diff -u -p -r1.12 gal-view-instance.c
--- gal/menus/gal-view-instance.c 10 Apr 2003 17:47:08 -0000 1.12
+++ gal/menus/gal-view-instance.c 15 Apr 2003 03:04:21 -0000
@@ -578,6 +578,9 @@ gal_view_instance_get_popup_menu (GalVie
add_popup_menu_item (ret_val + i++, N_("Define Views..."), G_CALLBACK (define_views_cb), instance);
e_popup_menu_copy_1 (ret_val + i++, &terminator);
+ if (id)
+ g_free (id);
+
return ret_val;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]