alloc

- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

Functions
alloc
Complete List of ArrayFire Functions ArrayFire Functions by Category » Functions to create and modify Arrays » | Managing devices in ArrayFire

Allocate memory using the ArrayFire memory manager. More...

## Functions
AFAPI af_err | af_alloc_device (void **ptr, const dim_t bytes)
| This device memory returned by this function can only be freed using af_free_device. More...
AFAPI void * | alloc (const size_t elements, const dtype type)
| Allocates memory using ArrayFire's memory manager. More...
template<typename T >
T * | alloc (const size_t elements)
| Allocates memory using ArrayFire's memory manager. More...

## Detailed Description

Allocate memory using the ArrayFire memory manager.

This function will allocate memory on the device and return a pointer to it. The memory is allocated using ArrayFire's memory manager which has some different characteristics to standard method of memory allocation

## Function Documentation

AFAPI af_err af_alloc_device | ( | void ** | ptr,
|  | const dim_t | bytes
| ) |  |

This device memory returned by this function can only be freed using af_free_device.

AFAPI void* af::alloc | ( | const size_t | elements,
|  | const dtype | type
| ) |  |

Allocates memory using ArrayFire's memory manager.

Allocate memory using the ArrayFire memory manager. This function will allocate memory on the device and return a pointer to it. The memory is allocated using ArrayFire's memory manager which has some different characteristics to standard method of memory allocation

Parameters

  [in] | elements | the number of elements to allocate
  [in] | type | is the type of the elements to allocate

Returns
  the pointer to the memory

Note
  The device memory returned by this function is only freed if af::free() is called explicitly

T* af::alloc | ( | const size_t | elements | ) |

Allocates memory using ArrayFire's memory manager.

Allocate memory using the ArrayFire memory manager. This function will allocate memory on the device and return a pointer to it. The memory is allocated using ArrayFire's memory manager which has some different characteristics to standard method of memory allocation

Parameters

  [in] | elements | the number of elements to allocate

Returns
  the pointer to the memory

Note
  the size of the memory allocated is the number of `elements` * sizeof(type)
  The device memory returned by this function is only freed if af::free() is called explicitly