Skip to content

Commit

Permalink
pycuampcor: deallocate memory objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Lijun Zhu committed Dec 14, 2023
1 parent ed9b142 commit 51af91d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
49 changes: 49 additions & 0 deletions contrib/PyCuAmpcor/src/cuAmpcorChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,55 @@ cuAmpcorChunk::cuAmpcorChunk(cuAmpcorParameter *param_, GDALImage *reference_, G
// destructor
cuAmpcorChunk::~cuAmpcorChunk()
{
corrNormalizerOverSampled.release();
corrNormalizerRaw.release();

if(param->oversamplingMethod) {
delete corrSincOverSampler;
}
else {
delete corrOverSampler;
}
if(param->algorithm == 0) {
delete cuCorrFreqDomain;
delete cuCorrFreqDomain_OverSampled;
}

delete ChunkOffsetDown ;
delete ChunkOffsetAcross ;
delete c_referenceBatchRaw;
delete c_secondaryBatchRaw;
delete r_referenceBatchRaw;
delete r_secondaryBatchRaw;
delete c_secondaryBatchZoomIn;
delete c_referenceBatchOverSampled;
delete c_secondaryBatchOverSampled;
delete r_referenceBatchOverSampled;
delete r_secondaryBatchOverSampled;
delete referenceBatchOverSampler;
delete secondaryBatchOverSampler;

delete r_corrBatchRaw;
delete r_corrBatchZoomIn;
delete r_corrBatchZoomInAdjust;
delete r_corrBatchZoomInOverSampled;
delete offsetInit;
delete offsetZoomIn;
delete offsetFinal;
delete maxLocShift;
delete corrMaxValue;

delete r_corrBatchRawZoomIn;
delete i_corrBatchZoomInValid;
delete r_corrBatchSum;
delete i_corrBatchValidCount;
delete i_maxloc;
delete r_maxval;
delete r_snrValue;
delete r_covValue;

// end of deletions

}

// end of file
3 changes: 2 additions & 1 deletion contrib/PyCuAmpcor/src/cuAmpcorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ void cuAmpcorController::runAmpcor()

for (int ist=0; ist<param->nStreams; ist++)
{
checkCudaErrors(cudaStreamDestroy(streams[ist]));
// cufftplan etc are stream dependent, need to be deleted before stream is destroyed
delete chunk[ist];
checkCudaErrors(cudaStreamDestroy(streams[ist]));
}

delete referenceImage;
Expand Down

0 comments on commit 51af91d

Please sign in to comment.