Skip to content

Commit

Permalink
Fixed memory leak with Cuda context manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Rit committed Oct 13, 2014
1 parent daaac4c commit 435c858
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions utilities/ITKCudaCommon/include/itkCudaDataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ class GPUMemPointer: public LightObject
void Allocate(size_t bufferSize)
{
m_BufferSize = bufferSize;
CUDA_CHECK(cuCtxSetCurrent(*(itk::CudaContextManager::GetInstance()->GetCurrentContext()))); // (peter) added this line
CUDA_CHECK(cudaMalloc(&m_GPUBuffer, bufferSize));
}

~GPUMemPointer()
{
if(m_GPUBuffer)
{
CUDA_CHECK(cuCtxSetCurrent(*(itk::CudaContextManager::GetInstance()->GetCurrentContext()))); // (peter) added this line
CUDA_CHECK(cudaFree(m_GPUBuffer));
m_GPUBuffer = 0;
}
Expand Down
1 change: 1 addition & 0 deletions utilities/ITKCudaCommon/src/itkCudaDataManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace itk
CudaDataManager::CudaDataManager()
{
m_ContextManager = CudaContextManager::GetInstance();
CUDA_CHECK(cuCtxSetCurrent(*(m_ContextManager->GetCurrentContext())));
m_CPUBuffer = NULL;
m_GPUBuffer = GPUMemPointer::New();
this->Initialize();
Expand Down

0 comments on commit 435c858

Please sign in to comment.