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.
This commit is contained in:
Robert Maynard 2019-04-29 15:51:19 -04:00
parent 33a30299d7
commit 8ef2c4be72

@ -43,9 +43,20 @@ void TransferInfoArray::updateDevice(vtkm::cont::DeviceAdapterId devId,
void TransferInfoArray::releaseDevice()
{
this->DeviceId = vtkm::cont::DeviceAdapterTagUndefined{};
this->Device = nullptr; //The device transfer state own this pointer
this->DeviceTransferState = nullptr; //release the device transfer state
this->HostCopyOfDevice.release(); //we own this pointer so release it
this->Device = nullptr; //The device transfer state own this pointer
if (this->DeviceTransferState == nullptr)
{ //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()