diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2017-02-17 15:56:36 +0100 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2017-02-17 15:56:36 +0100 |
commit | aa325035704f932e29217274aeab26ae46847a7b (patch) | |
tree | 405e7e0a8017f55048c3607b4455d70e591a7d41 /cuda/3d/astra3d.cu | |
parent | 8de844c3521d9ee54087927923b932e1016c5b90 (diff) | |
download | astra-aa325035704f932e29217274aeab26ae46847a7b.tar.gz astra-aa325035704f932e29217274aeab26ae46847a7b.tar.bz2 astra-aa325035704f932e29217274aeab26ae46847a7b.tar.xz astra-aa325035704f932e29217274aeab26ae46847a7b.zip |
Fix cuda3d geometry memory leaks
Diffstat (limited to 'cuda/3d/astra3d.cu')
-rw-r--r-- | cuda/3d/astra3d.cu | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/cuda/3d/astra3d.cu b/cuda/3d/astra3d.cu index 8e0946e..30cbe1b 100644 --- a/cuda/3d/astra3d.cu +++ b/cuda/3d/astra3d.cu @@ -319,6 +319,9 @@ AstraSIRT3d::~AstraSIRT3d() delete[] pData->projs; pData->projs = 0; + delete[] pData->parprojs; + pData->parprojs = 0; + cudaFree(pData->D_projData.ptr); pData->D_projData.ptr = 0; @@ -702,6 +705,9 @@ AstraCGLS3d::~AstraCGLS3d() delete[] pData->projs; pData->projs = 0; + delete[] pData->parprojs; + pData->parprojs = 0; + cudaFree(pData->D_projData.ptr); pData->D_projData.ptr = 0; @@ -1133,19 +1139,27 @@ bool astraCudaBP(float* pfVolume, const float* pfProjections, cudaError_t err = cudaGetLastError(); // Ignore errors caused by calling cudaSetDevice multiple times - if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) + if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) { + delete[] pParProjs; + delete[] pConeProjs; return false; + } } cudaPitchedPtr D_volumeData = allocateVolumeData(dims); ok = D_volumeData.ptr; - if (!ok) + if (!ok) { + delete[] pParProjs; + delete[] pConeProjs; return false; + } cudaPitchedPtr D_projData = allocateProjectionData(dims); ok = D_projData.ptr; if (!ok) { + delete[] pParProjs; + delete[] pConeProjs; cudaFree(D_volumeData.ptr); return false; } @@ -1156,6 +1170,8 @@ bool astraCudaBP(float* pfVolume, const float* pfProjections, ok &= zeroVolumeData(D_volumeData, dims); if (!ok) { + delete[] pParProjs; + delete[] pConeProjs; cudaFree(D_volumeData.ptr); cudaFree(D_projData.ptr); return false; @@ -1168,6 +1184,8 @@ bool astraCudaBP(float* pfVolume, const float* pfProjections, ok &= copyVolumeFromDevice(pfVolume, D_volumeData, dims, dims.iVolX); + delete[] pParProjs; + delete[] pConeProjs; cudaFree(D_volumeData.ptr); cudaFree(D_projData.ptr); @@ -1208,19 +1226,27 @@ bool astraCudaBP_SIRTWeighted(float* pfVolume, cudaError_t err = cudaGetLastError(); // Ignore errors caused by calling cudaSetDevice multiple times - if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) + if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) { + delete[] pParProjs; + delete[] pConeProjs; return false; + } } cudaPitchedPtr D_pixelWeight = allocateVolumeData(dims); ok = D_pixelWeight.ptr; - if (!ok) + if (!ok) { + delete[] pParProjs; + delete[] pConeProjs; return false; + } cudaPitchedPtr D_volumeData = allocateVolumeData(dims); ok = D_volumeData.ptr; if (!ok) { + delete[] pParProjs; + delete[] pConeProjs; cudaFree(D_pixelWeight.ptr); return false; } @@ -1228,6 +1254,8 @@ bool astraCudaBP_SIRTWeighted(float* pfVolume, cudaPitchedPtr D_projData = allocateProjectionData(dims); ok = D_projData.ptr; if (!ok) { + delete[] pParProjs; + delete[] pConeProjs; cudaFree(D_pixelWeight.ptr); cudaFree(D_volumeData.ptr); return false; @@ -1244,6 +1272,8 @@ bool astraCudaBP_SIRTWeighted(float* pfVolume, processVol3D<opInvert>(D_pixelWeight, dims); if (!ok) { + delete[] pParProjs; + delete[] pConeProjs; cudaFree(D_pixelWeight.ptr); cudaFree(D_volumeData.ptr); cudaFree(D_projData.ptr); |