A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
freeV2
ArrayFire Functions | ArrayFire Functions by Category » Functions to create and modify Arrays » Managing devices in ArrayFire

Returns memory to ArrayFire's memory manager. The memory will return to the memory pool. More...

## Functions
AFAPI void | free (const void *ptr)
| Returns memory to ArrayFire's memory manager. The memory will return to the memory pool.
AFAPI void | freeV2 (const void *ptr)
| Returns memory to ArrayFire's memory manager. The memory will return to the memory pool.
AFAPI af_err | af_free_device (void *ptr)
| Returns memory to ArrayFire's memory manager.
AFAPI af_err | af_free_device_v2 (void *ptr)
| Returns memory to ArrayFire's memory manager.

## Detailed Description

Returns memory to ArrayFire's memory manager. The memory will return to the memory pool.

Releases control of the memory allocated by af::allocV2 functions to ArrayFire's memory manager. ArrayFire may reuse the memory for subsequent operations. This memory should not be used by the client after this point.

## Function Documentation

## ◆ af_free_device()

AFAPI af_err af_free_device | ( | void * | ptr | ) |

Returns memory to ArrayFire's memory manager.

This function will free a device pointer even if it has been previously locked.

Parameters

  [in] | ptr | The pointer allocated by af_alloc_device to be freed

Deprecated
  Use af_free_device_v2 instead. The new function handles the new behavior of the af_alloc_device_v2 function.

## ◆ af_free_device_v2()

AFAPI af_err af_free_device_v2 | ( | void * | ptr | ) |

Returns memory to ArrayFire's memory manager.

This function will free a device pointer even if it has been previously locked.

Parameters

  [in] | ptr | The pointer allocated by af_alloc_device_v2 to be freed

Note
  this function will not work for pointers allocated using the af_alloc_device function for all backends

## ◆ free()

AFAPI void free | ( | const void * | ptr | ) |

Returns memory to ArrayFire's memory manager. The memory will return to the memory pool.

Releases control of the memory allocated by af::allocV2 functions to ArrayFire's memory manager. ArrayFire may reuse the memory for subsequent operations. This memory should not be used by the client after this point.

Parameters

  [in] | ptr | the memory allocated by the af::alloc function that will be freed

Note
  This function will free a device pointer even if it has been previously locked.

Deprecated
  Use af::freeV2 instead. af_alloc_device_v2 returns a cl_mem object instead of the cl::Buffer object for the OpenCL backend. Otherwise the functionallity is identical

## ◆ freeV2()

AFAPI void freeV2 | ( | const void * | ptr | ) |

Returns memory to ArrayFire's memory manager. The memory will return to the memory pool.

Releases control of the memory allocated by af::allocV2 functions to ArrayFire's memory manager. ArrayFire may reuse the memory for subsequent operations. This memory should not be used by the client after this point.

Parameters

  [in] | ptr | The pointer returned by af::allocV2

This function will free a device pointer even if it has been previously locked.