# Allocate

> Allocates enough memory to store length elements of struct T.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## Allocate\<T>(BlobArray\<T>, int)

Allocates enough memory to store `length` elements of struct `T`.

```csharp
public BlobBuilderArray<T> Allocate<T>(ref BlobArray<T> ptr, int length) where T : struct
```

### Parameters

**** (\[BlobArray\<T>]\(/engine/7000.0/script-reference/unity/entities/blobarray1)): A reference to a BlobArray field in a blob asset.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of elements to allocate.

### Returns

| Type                                                                                        | Description                                                                      |
| ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [BlobBuilderArray\<T>](/engine/7000.0/script-reference/unity/entities/blobbuilderarray1.md) | A reference to the newly allocated array as a mutable BlobBuilderArray instance. |

## Allocate\<T>(BlobArray\<T>, int, int)

Allocates enough memory to store `length` elements of struct `T`.

```csharp
public BlobBuilderArray<T> Allocate<T>(ref BlobArray<T> ptr, int length, int alignment) where T : struct
```

### Parameters

**** (\[BlobArray\<T>]\(/engine/7000.0/script-reference/unity/entities/blobarray1)): A reference to a BlobArray field in a blob asset.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of elements to allocate.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The alignment of the allocated memory.

### Returns

| Type                                                                                        | Description                                                                      |
| ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [BlobBuilderArray\<T>](/engine/7000.0/script-reference/unity/entities/blobbuilderarray1.md) | A reference to the newly allocated array as a mutable BlobBuilderArray instance. |

## Allocate\<T>(BlobPtr\<T>)

Allocates enough memory to store a struct of type `T`.

```csharp
public ref T Allocate<T>(ref BlobPtr<T> ptr) where T : struct
```

### Parameters

**** (\[BlobPtr\<T>]\(/engine/7000.0/script-reference/unity/entities/blobptr1)): A reference to a blob pointer field in a blob asset.

### Returns

| Type | Description                                |
| ---- | ------------------------------------------ |
| T    | A reference to the newly allocated struct. |
