cudaHostUnregister for CPU buffer which is already deallocated - problem ?

In our workflow, we are doing a page-locking of a existing CPU buffer ‘buf’ in a ‘lazy’ (on-demand) way, via ‘cudaHostRegister’.
The ‘cudaHostUnregister’ call of the same CPU buffer ‘buf’ may occur after the respective CPU buffer is already deallocated.

Is that a problem (in windows or Linux) ? It seems to be not.

All cudaHostUnregister is doing is making the memory range pageable again. You’re just removing the memory all together. There’s probably no reason to even run cudaHostUnregister. I ran both scenarios, on Linux, and had no issues.

Hi, thanks for the information. Well, there is at leat on windows a hard limit to the size of page-locked memory, that’s why it is better to unregister it when the corresponding CPU beffer is freed.