From da62ca9ec060334616e0e99d4c927258fc4cf5b2 Mon Sep 17 00:00:00 2001 From: Takanori Nakane Date: Tue, 2 Dec 2014 14:47:37 +0900 Subject: Fix huge memory leak in hdfsee when re-loading events. Probably we need image_free(). --- libcrystfel/src/hdf5-file.c | 4 ++++ src/dw-hdfsee.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 5eb8e768..fceff0e7 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -1188,6 +1188,8 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev, ERROR("Error selecting memory dataspace for panel %s\n", p->name); free(buf); + free(f_offset); + free(f_count); return 1; } @@ -1197,6 +1199,8 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev, ERROR("Couldn't read data for panel %s\n", p->name); free(buf); + free(f_offset); + free(f_count); return 1; } H5Dclose(f->dh); diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index 55515f2c..f8d49989 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -1904,12 +1904,18 @@ static gint displaywindow_newevent(GtkMenuItem *item, struct newev *ne) { gboolean a; int fail; + int i; if ( ne->dw->not_ready_yet ) return 0; a = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(ne->widget)); if ( !a ) return 0; + float *old_data = ne->dw->image->data; + uint16_t *old_flags = ne->dw->image->flags; + float **old_dp = ne->dw->image->dp; + int **old_bad = ne->dw->image->bad; + fail = hdf5_read2(ne->dw->hdfile, ne->dw->image, ne->dw->ev_list->events[ne->new_ev], 0); if ( fail ) { @@ -1921,6 +1927,14 @@ static gint displaywindow_newevent(GtkMenuItem *item, struct newev *ne) do_filters(ne->dw); displaywindow_update(ne->dw); + for (i = 0; i < ne->dw->image->det->n_panels; i++) { + free(old_dp[i]); + free(old_bad[i]); + } + free(old_data); + free(old_flags); + free(old_dp); + free(old_bad); return 0; } -- cgit v1.2.3