thrust

◆ free()

template<typename DerivedPolicy , typename Pointer >
__host__ __device__ void thrust::free ( const thrust::detail::execution_policy_base< DerivedPolicy > &  system,
Pointer  ptr 
)

free deallocates the storage previously allocated by thrust::malloc.

Parameters
systemThe Thrust system with which the storage is associated.
ptrA pointer previously returned by thrust::malloc. If ptr is null, free does nothing.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
Precondition
ptr shall have been returned by a previous call to thrust::malloc(system, n) or thrust::malloc<T>(system, n) for some type T.

The following code snippet demonstrates how to use free to deallocate a range of memory previously allocated with thrust::malloc.

#include <thrust/memory.h>
...
// allocate storage for 100 ints with thrust::malloc
const int N = 100;
thrust::device_system_tag device_sys;
thrust::pointer<int,thrust::device_system_tag> ptr = thrust::malloc<int>(device_sys, N);
// mainpulate memory
...
// deallocate ptr with thrust::free
thrust::free(device_sys, ptr);

Referenced by thrust::mr::disjoint_unsynchronized_pool_resource< Upstream, Bookkeeper >::disjoint_unsynchronized_pool_resource(), and thrust::mr::disjoint_unsynchronized_pool_resource< Upstream, Bookkeeper >::~disjoint_unsynchronized_pool_resource().