Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Allocate

Allocates memory directly from an allocator.
Read time 1 minuteLast updated 13 days ago

Definition

  • Type: Method
  • Namespace: Unity.Collections
  • Assembly: UnityEngine.ManagedKernelModule

Allocate<T>(T, int, int, int)

Allocates memory directly from an allocator.
public static void* Allocate<T>(this ref T t, int sizeOf, int alignOf, int items = 1) where T : unmanaged, AllocatorManager.IAllocator

Parameters

t

T
The allocator of type T used to allocator memory.

sizeOf

The number of bytes to allocate to item.

alignOf

The alignment in bytes.

items

The number of items. Defaults to 1.

Returns

Type

Description

void*A pointer to the allocated memory.

Allocate(AllocatorHandle, int, int, int)

Allocates memory from an allocator.
public static void* Allocate(AllocatorManager.AllocatorHandle handle, int itemSizeInBytes, int alignmentInBytes, int items = 1)

Parameters

A handle to the allocator.

itemSizeInBytes

The number of bytes to allocate.

alignmentInBytes

The alignment in bytes (must be a power of two).

items

The number of values to allocate space for. Defaults to 1.

Returns

Type

Description

void*A pointer to the allocated memory.

Allocate<T>(AllocatorHandle, int)

Allocates enough memory for an unmanaged value of a given type.
public static T* Allocate<T>(AllocatorManager.AllocatorHandle handle, int items = 1) where T : unmanaged

Parameters

A handle to the allocator.

items

The number of values to allocate for space for. Defaults to 1.

Returns

Type

Description

<T>*A pointer to the allocated memory.