diff options
author | Thomas White <taw@physics.org> | 2010-02-19 18:40:01 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-02-19 18:40:01 +0100 |
commit | d8115c2fc3bc1c69b751f907e323acc45f6a758a (patch) | |
tree | 0d4961d1ba1fc2cbd5ee60409657c144a19a703f | |
parent | 3542ac97a332f2657c7a69b93bf1133ca81967cb (diff) |
Fix various exciting (and otherwise) memory leaks
-rw-r--r-- | src/diffraction-gpu.c | 11 | ||||
-rw-r--r-- | src/pattern_sim.c | 5 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c index 330a676e..b9485241 100644 --- a/src/diffraction-gpu.c +++ b/src/diffraction-gpu.c @@ -137,6 +137,7 @@ static cl_program load_program(const char *filename, cl_context ctx, return 0; } + free(source); *err = CL_SUCCESS; return prog; } @@ -329,6 +330,9 @@ void get_diffraction_gpu(struct gpu_context *gctx, struct image *image, } } + + clEnqueueUnmapMemObject(gctx->cq, gctx->diff, diff_ptr, 0, NULL, NULL); + clEnqueueUnmapMemObject(gctx->cq, gctx->tt, tt_ptr, 0, NULL, NULL); } @@ -349,8 +353,8 @@ struct gpu_context *setup_gpu(int no_sfac, struct image *image, /* Generate structure factors if required */ if ( !no_sfac ) { - if ( image->molecule->reflections == NULL ) { - get_reflections_cached(image->molecule, + if ( molecule->reflections == NULL ) { + get_reflections_cached(molecule, ph_lambda_to_en(image->lambda)); } } @@ -413,13 +417,14 @@ struct gpu_context *setup_gpu(int no_sfac, struct image *image, } } gctx->sfacs = clCreateBuffer(gctx->ctx, - CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, + CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sfac_size, sfac_ptr, &err); if ( err != CL_SUCCESS ) { ERROR("Couldn't allocate sfac memory\n"); free(gctx); return NULL; } + free(sfac_ptr); gctx->tt_size = image->width*image->height*sizeof(cl_float); gctx->tt = clCreateBuffer(gctx->ctx, CL_MEM_WRITE_ONLY, gctx->tt_size, diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 54d9ab88..e2f80b02 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -363,5 +363,10 @@ skip: cleanup_gpu(gctx); } + free(image.det.panels); + free(powder); + free(image.molecule->reflections); + free(image.molecule); + return 0; } |