Commit 8ef2c4be authored by Robert Maynard's avatar Robert Maynard
Browse files

TransferInfo doesn't leak when holding VirtualObjectTransferShareWithControl

When TransferInfo is given memory from VirtualObjectTransferShareWithControl
it doesn't have a bound function ptr for the destruction. In those cases
we need to make sure the HostCopyOfDevice is properly deleted, otherwise
we will cause a memory leak.
parent 33a30299
...@@ -43,9 +43,20 @@ void TransferInfoArray::updateDevice(vtkm::cont::DeviceAdapterId devId, ...@@ -43,9 +43,20 @@ void TransferInfoArray::updateDevice(vtkm::cont::DeviceAdapterId devId,
void TransferInfoArray::releaseDevice() void TransferInfoArray::releaseDevice()
{ {
this->DeviceId = vtkm::cont::DeviceAdapterTagUndefined{}; this->DeviceId = vtkm::cont::DeviceAdapterTagUndefined{};
this->Device = nullptr; //The device transfer state own this pointer this->Device = nullptr; //The device transfer state own this pointer
this->DeviceTransferState = nullptr; //release the device transfer state if (this->DeviceTransferState == nullptr)
this->HostCopyOfDevice.release(); //we own this pointer so release it { //When the DeviceTransferState is a nullptr it means that
//that the device and host share memory. In that case we need to free
//the host copy
this->HostCopyOfDevice.reset(nullptr);
}
else
{
//The DeviceTransferState holds ownership of HostCopyOfDevice so we only
//need to delete DeviceTransferState, as it will do the rest
this->DeviceTransferState = nullptr; //release the device transfer state
this->HostCopyOfDevice.release();
}
} }
void TransferInfoArray::releaseAll() void TransferInfoArray::releaseAll()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment