[][src]Function rustacuda::memory::cuda_free

pub unsafe fn cuda_free<T>(p: DevicePointer<T>) -> CudaResult<()>

Free memory allocated with cuda_malloc.

Errors

If freeing memory fails, returns the CUDA error value. If the given pointer is null, returns InvalidValue.

Safety

The given pointer must have been allocated with cuda_malloc, or null. The caller is responsible for ensuring that no other pointers to the deallocated buffer exist.

Examples

use rustacuda::memory::*;
unsafe {
    let device_buffer = cuda_malloc::<u64>(5).unwrap();
    // Free allocated memory.
    cuda_free(device_buffer).unwrap();
}