Celebrandil / CudaSift

A CUDA implementation of SIFT for NVidia GPUs (1.2 ms on a GTX 1060)
MIT License
860 stars 285 forks source link

This can cause memory leaks #83

Closed JustWB13 closed 1 year ago

JustWB13 commented 2 years ago

For some reason, I ported CudaSift to Visual Studio 2019(Cuda 11.6) for testing and found that some codes in cudaSiftH.cu may cause memory leaks. Here are the codes, line 134 to 135, in function ExtractSift.

if (!tempMemory)
    safeCall(cudaFree(memoryTmp));

There seems to be something wrong with the judgement logic here. According to these codes, if tempMemory is NULL then it should be freed. But actually, before we call the function ExtractSift, tempMemory has been allocated memory in GPU. So when the function ends, the memory for tempMemory will not be freed, and it will cause memory leaks.

Revised version here.

if (tempMemory)
    safeCall(cudaFree(memoryTmp));