# Allocate

> Allocate space in a buffer.

## Definition

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

## Allocate\<T>()

Allocate space in a buffer.

```csharp
public ref T Allocate<T>() where T : unmanaged
```

### Returns

| Type | Description                    |
| ---- | ------------------------------ |
| T    | A reference to the allocation. |

### Remarks

The space is allocated in the buffer which was specified with [NativeStream.Writer.BeginForEachIndex](/engine/6000.7/script-reference/unity/collections/nativestream/writer/beginforeachindex.md).

## Allocate(int)

Allocate space in a buffer.

```csharp
public byte* Allocate(int size)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes to allocate.

### Returns

| Type                                                         | Description     |
| ------------------------------------------------------------ | --------------- |
| [byte\*](https://learn.microsoft.com/dotnet/api/system.byte) | The allocation. |

### Remarks

The space is allocated in the buffer which was specified with [NativeStream.Writer.BeginForEachIndex](/engine/6000.7/script-reference/unity/collections/nativestream/writer/beginforeachindex.md).
