# MemoryLabel

> Represents a memory label used for profiling and tracking memory allocations in Unity.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections](/engine/6000.5/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public readonly struct MemoryLabel
```

## Remarks

Memory labels are useful when you want to group allocations for specific objects or systems. They can help in debugging memory issues and understanding the memory footprint of your application.

When you create a [NativeArray\<T>](/engine/6000.5/script-reference/unity/collections/nativearray1.md) or [UnsafeUtility.Malloc](/engine/6000.5/script-reference/unity/collections/lowlevel/unsafe/unsafeutility/malloc.md), you can specify a memory label to associate with that allocation.

Memory labels can only be used with allocators that support memory labeling, i.e. [Allocator.Persistent](/engine/6000.5/script-reference/unity/collections/allocator/persistent.md) and [Allocator.Domain](/engine/6000.5/script-reference/unity/collections/allocator/domain.md).

## Examples

```csharp
using UnityEngine;
using Unity.Collections;

public class MemoryLabelExample : MonoBehaviour
{
    static readonly MemoryLabel myMemoryLabel = new MemoryLabel("MyArea", "MyObject", Allocator.Persistent);

    NativeArray<int> myArray;

    void Start()
    {
        // Create array with fixed length and memory label
        myArray = new NativeArray<int>(10, myMemoryLabel);

        for (int i = 0; i < myArray.Length; i++)
        {
            myArray[i] = i * 2;
        }
    }

    public void OnDestroy()
    {
        // Dispose of the array to avoid leaks
        if (myArray.IsCreated)
        {
            myArray.Dispose();
        }
    }
}
```

## Constructors

| Constructor                                                                                                                                   | Description                                                                                                               |
| --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| [MemoryLabel(System.String,System.String,Unity.Collections.Allocator)](/engine/6000.5/script-reference/unity/collections/memorylabel/ctor.md) | Initializes a new instance of the [MemoryLabel](/engine/6000.5/script-reference/unity/collections/memorylabel.md) struct. |

## Properties

| Property                                                                                | Description                                                         |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| [IsCreated](/engine/6000.5/script-reference/unity/collections/memorylabel/iscreated.md) | Gets a value indicating whether this memory label has been created. |

## Static Methods

| Method                                                                                                  | Description                                                          |
| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [SupportsAllocator](/engine/6000.5/script-reference/unity/collections/memorylabel/supportsallocator.md) | Determines whether the specified allocator supports memory labeling. |
