diff options
author | Takanori Nakane <nakane.t@gmail.com> | 2014-12-02 14:47:37 +0900 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-12-02 15:40:50 +0100 |
commit | da62ca9ec060334616e0e99d4c927258fc4cf5b2 (patch) | |
tree | bacb063420e3c4e67cc66bb0294fe6762fbc3440 | |
parent | 45da3ff62029e2416afb8e46e846c7ae910f0147 (diff) |
Fix huge memory leak in hdfsee when re-loading events.
Probably we need image_free().
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 4 | ||||
-rw-r--r-- | src/dw-hdfsee.c | 14 |
2 files changed, 18 insertions, 0 deletions
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; } |