Skip to content

Memory fix C code

Yang, Diyu requested to merge memory_fix_python into master

Created by: dyang37

This PR completes the memory fix in C code, plus some memory-related improvements in Cython interface. It contains the following fixes:

  1. Installed new multialloc routine, and replaced all mem_alloc_2D and mem_alloc_3D functions with multialloc. This is to handle issue #10 (closed) .
  2. In C code, remove unnecessary copy of pointer arrays for img.vox, img.proxMapInput, sino.vox, sino.wgt in interface.c.
  3. In Cython interface, initialize recon image directly with init image. This avoids unnecessary memory re-allocation of the recon image.
  4. In C code, added functionality of checking whether prox image and recon image are from the same memory address, and make a copy when necessary. This is to handle the corner case that might occur after fix 3, where x_init and prox_image might be the same variable.
  5. In Cython interface, only make contiguous array when necessary.

Testing

  1. recon testing: Cleared sys matrix cache, and ran demo_3D_shepp_logan.py and demo_mace3D.py. Results for both experiments are visually the same as before.
  2. Unit test for fix 4: When doing proximal map mode recon, provide the same variable input of init image and proximal image. The memory address detection mechanism is triggered (as expected).

Merge request reports