docs.unity3d.com
    Show / Hide Table of Contents

    Class AllocatorManager

    Support for management of custom memory allocators

    Inheritance
    Object
    AllocatorManager
    Namespace: Unity.Collections
    Syntax
    public static class AllocatorManager : object

    Fields

    AudioKernel

    Corresponds to Allocator.AudioKernel.

    Declaration
    public static readonly AllocatorManager.AllocatorHandle AudioKernel
    Field Value
    Type Description
    AllocatorManager.AllocatorHandle

    FirstUserIndex

    User-defined allocator index.

    Declaration
    public const ushort FirstUserIndex = null
    Field Value
    Type Description
    UInt16

    Invalid

    Corresponds to Allocator.Invalid.

    Declaration
    public static readonly AllocatorManager.AllocatorHandle Invalid
    Field Value
    Type Description
    AllocatorManager.AllocatorHandle

    None

    Corresponds to Allocator.None.

    Declaration
    public static readonly AllocatorManager.AllocatorHandle None
    Field Value
    Type Description
    AllocatorManager.AllocatorHandle

    Persistent

    Corresponds to Allocator.Persistent.

    Declaration
    public static readonly AllocatorManager.AllocatorHandle Persistent
    Field Value
    Type Description
    AllocatorManager.AllocatorHandle

    Temp

    Corresponds to Allocator.Temp.

    Declaration
    public static readonly AllocatorManager.AllocatorHandle Temp
    Field Value
    Type Description
    AllocatorManager.AllocatorHandle

    TempJob

    Corresponds to Allocator.TempJob.

    Declaration
    public static readonly AllocatorManager.AllocatorHandle TempJob
    Field Value
    Type Description
    AllocatorManager.AllocatorHandle

    Methods

    Allocate(AllocatorManager.AllocatorHandle, Int32, Int32, Int32)

    Allocate memory from an allocator

    Declaration
    public static void *Allocate(AllocatorManager.AllocatorHandle handle, int itemSizeInBytes, int alignmentInBytes, int items = 1)
    Parameters
    Type Name Description
    AllocatorManager.AllocatorHandle handle

    Handle to allocator to allocate from

    Int32 itemSizeInBytes

    Number of bytes to allocate

    Int32 alignmentInBytes

    Required alignment in bytes (must be a power of two)

    Int32 items

    Number of elements to allocate

    Returns
    Type Description
    Void*

    A pointer to the allocated memory block

    Allocate<T>(AllocatorManager.AllocatorHandle, Int32)

    Allocate memory suitable for a type {T} from an allocator

    Declaration
    public static T*Allocate<T>(AllocatorManager.AllocatorHandle handle, int items = 1)
        where T : struct
    Parameters
    Type Name Description
    AllocatorManager.AllocatorHandle handle

    Handle to allocator to allocate from

    Int32 items

    Number of elements to allocate

    Returns
    Type Description
    T*

    A pointer to the allocated memory block

    Type Parameters
    Name Description
    T

    Element type to allocate

    Free(AllocatorManager.AllocatorHandle, Void*)

    Free previously allocated memory

    Declaration
    public static void Free(AllocatorManager.AllocatorHandle handle, void *pointer)
    Parameters
    Type Name Description
    AllocatorManager.AllocatorHandle handle

    Handle to allocator to free memory in

    Void* pointer

    Previously allocated pointer

    Free(AllocatorManager.AllocatorHandle, Void*, Int32, Int32, Int32)

    Free previously allocated memory

    Declaration
    public static void Free(AllocatorManager.AllocatorHandle handle, void *pointer, int itemSizeInBytes, int alignmentInBytes, int items = 1)
    Parameters
    Type Name Description
    AllocatorManager.AllocatorHandle handle

    Handle to allocator to free memory in

    Void* pointer

    Previously allocated pointer

    Int32 itemSizeInBytes

    Size used at allocation time

    Int32 alignmentInBytes

    Alignment used at allocation time

    Int32 items

    ignored

    Free<T>(AllocatorManager.AllocatorHandle, T*, Int32)

    Free previously allocated memory

    Declaration
    public static void Free<T>(AllocatorManager.AllocatorHandle handle, T*pointer, int items = 1)
        where T : struct
    Parameters
    Type Name Description
    AllocatorManager.AllocatorHandle handle

    Handle to allocator to free memory in

    T* pointer

    Previously allocated pointer

    Int32 items

    Number of elements to free (must be same as at allocation time)

    Type Parameters
    Name Description
    T

    Element type

    Initialize()

    Initializes SharedStatic allocator function table and allocator table, and installs default allocators.

    Declaration
    public static void Initialize()

    Register<T>(ref T)

    Type safe version of Register

    Declaration
    public static void Register<T>(this ref T t)
        where T : struct, AllocatorManager.IAllocator
    Parameters
    Type Name Description
    T t

    Reference to the allocator

    Type Parameters
    Name Description
    T

    The type of allocator to register

    Shutdown()

    Shut down

    Declaration
    public static void Shutdown()

    Try(ref AllocatorManager.Block)

    Looks up an allocator's allocate, free, or realloc function pointer from a table and invokes the function.

    Declaration
    public static int Try(ref AllocatorManager.Block block)
    Parameters
    Type Name Description
    AllocatorManager.Block block

    Block to allocate memory for.

    Returns
    Type Description
    Int32

    Error code of invoked function.

    Unregister<T>(ref T)

    Declaration
    public static void Unregister<T>(this ref T t)
        where T : struct, AllocatorManager.IAllocator
    Parameters
    Type Name Description
    T t
    Type Parameters
    Name Description
    T
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023