After running Update(), the RTK memory is not release

Hello, I built a rtk class using python and then wrapped the forward() and FDKbackward(). When I was doing forward and backward, I noticed that the memory usage was rising. I used python’s memory_profiler tool to analyze the memory usage and found that the Update() function takes up some memory but does not free it after the function ends. Even though I manually del deleted the variable, it still doesn’t work.
this is my code:

FDKType = rtk.CudaFDKConeBeamReconstructionFilter
fdk = FDKType.New()
fdk.Update()
image_gpu = fdk.GetOutput()
image = self.cuda2cpu(image_gpu)
del fdk
gc.collect()

and
fp = rtk.CudaForwardProjectionImageFilter.New()
fp.Update()
del fp

@simon.rit might want to comment.

Most of the (CPU and GPU) memory is contained in the image_gpu object, CudaFDKConeBeamReconstructionFilter does not use much memory. So if you don’t delete this one, I don’t expect a huge release of memory.

Could you provide a full self-contained example along with the RTK version to be able to reproduce the issue?

1 Like

Thank you for your reply. Your reference to “Most of the (CPU and GPU) memory is contained in the image_gpu object” is very helpful. I try to delete forward() and backward() outputs and find that it really release a lot of memory!

1 Like