# Free

> Frees an allocation.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

## Free(AllocatorHandle, void\*, int, int, int)

Frees an allocation.

```csharp
public static void Free(AllocatorManager.AllocatorHandle handle, void* pointer, int itemSizeInBytes, int alignmentInBytes, int items = 1)
```

### Parameters

**** (\[AllocatorHandle]\(/engine/6000.7/script-reference/unity/collections/allocatormanager/allocatorhandle)): A handle to the allocator.**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): A pointer to the allocated memory.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The size in bytes of the allocation.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The alignment in bytes (must be a power of two).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of values that the memory was allocated for.

### Remarks

For some allocators, the size of the allocation must be known to properly deallocate. Other allocators only need the pointer when deallocating and so will ignore `itemSizeInBytes`, `alignmentInBytes` and `items`.

## Free(AllocatorHandle, void\*)

Frees an allocation.

```csharp
public static void Free(AllocatorManager.AllocatorHandle handle, void* pointer)
```

### Parameters

**** (\[AllocatorHandle]\(/engine/6000.7/script-reference/unity/collections/allocatormanager/allocatorhandle)): A handle to the allocator.**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): A pointer to the allocated memory.

## Free\<T>(AllocatorHandle, \`\<>\*, int)

Frees an allocation.

```csharp
public static void Free<T>(AllocatorManager.AllocatorHandle handle, T* pointer, int items = 1) where T : unmanaged
```

### Parameters

**** (\[AllocatorHandle]\(/engine/6000.7/script-reference/unity/collections/allocatormanager/allocatorhandle)): A handle to the allocator.**** (\[\<T>\*]\(./)): A pointer to the allocated memory.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of values that the memory was allocated for.

### Remarks

For some allocators, the size of the allocation must be known to properly deallocate. Other allocators only need the pointer when deallocating and so  will ignore `T` and `items`.
