What will happen if leave the cuMemAllocHost locked memory unfreed?

I use Rust to program the CUDA apps.After I use the cuMemAllocHost to alloc a piece of memory.
I found that it is very slow to copy the data from normal memory to the alloced memory. So I just
use the “C” like memcpy to copy the source data from normal memory to alloced memory. It is Ok
to use the data, and the streams can parallel some computing . But the question is I cannot free the
alloced memory normally with cuMemFreeHost. it says the memory is invalid.
Could someone has any ideas about this? Or if I leave the alloced memory unfreed what will happened
to my system. Or it’s ok to leave it unfreed?


Note that this function may also return error codes from previous, asynchronous launches.

So I’d recommend to synchronize the device, retrieve any pending error codes before the call to cuMemFreeHost()

Also it’s OK to leave it unfreed, assuming your application terminates. Then the CUDA context will be torn down, which includes freeing this page locked host memory.

Thank you so much.