# ScratchpadAllocator

> A fast allocator which allocates memory from its scratchpad.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule
* **Implements:** [IAllocator](/engine/7000.0/script-reference/unity/collections/allocatormanager/iallocator.md), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
[BurstCompile]
public struct ScratchpadAllocator : AllocatorManager.IAllocator, IDisposable
```

## Properties

| Property                                                                                                     | Description                                                                                                                                                                          |
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Function](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/function.md)                   | All allocators must implement this property, in order to be installed in the custom allocator table.                                                                                 |
| [Handle](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/handle.md)                       | Retrieve the AllocatorHandle associated with this allocator. The handle is used as an index into a global table, for times when a reference to the allocator object isn't available. |
| [IsAutoDispose](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/isautodispose.md)         | Check whether this allocator will automatically dispose allocations.                                                                                                                 |
| [IsCustomAllocator](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/iscustomallocator.md) | Check whether this allocator is a custom allocator.                                                                                                                                  |
| [ToAllocator](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/toallocator.md)             | Retrieve the Allocator associated with this allocator handle.                                                                                                                        |

## Methods

| Method                                                                                                           | Description                                                                                                                                                                                                                  |
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AllocateNativeArray](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/allocatenativearray.md) | Allocate a NativeArray of type T from memory that's guaranteed to remain valid until [ScratchpadAllocator.Rewind](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/rewind.md) is called on the Scratchpad. |
| [AllocateNativeList](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/allocatenativelist.md)   | Allocate a NativeList of type T from memory that's guaranteed to remain valid until [ScratchpadAllocator.Rewind](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/rewind.md) is called on the Scratchpad.  |
| [Dispose](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/dispose.md)                         | Dispose the allocator.                                                                                                                                                                                                       |
| [GetAvailableBytes](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/getavailablebytes.md)     | Get remaining bytes that are available to allocate.                                                                                                                                                                          |
| [Initialize](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/initialize.md)                   | Initializes the allocator. Must be called before first use.                                                                                                                                                                  |
| [Rewind](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/rewind.md)                           | Rewind the allocator; invalidate all allocations made from it.                                                                                                                                                               |
| [Try](/engine/7000.0/script-reference/unity/entities/scratchpadallocator/try.md)                                 | Try to allocate, free, or reallocate a block of memory.                                                                                                                                                                      |
