Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::IO::IStreamerTypes::RequestMemoryAllocator Class Referenceabstract

#include <IStreamerTypes.h>

Inherited by AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.

Public Member Functions

virtual void LockAllocator ()=0
 Called when the Streamer is about to start allocating memory for a request. This will be called multiple times.
 
virtual void UnlockAllocator ()=0
 
virtual RequestMemoryAllocatorResult Allocate (u64 minimalSize, u64 recommendeSize, size_t alignment)=0
 
virtual void Release (void *address)=0
 

Detailed Description

RequestMemoryAllocators can be used to provide a mechanic to allow the Streamer to allocate memory right before the request is processed. This can be useful in avoiding having to track memory buffers as these are managed by Streamer until the buffer is claimed. It can also help reduce peak memory if processing data requires temporary buffers as these do not all have to be created upfront. The RequestMemoryAllocator typically outlives the request and a completed request does not mean the allocator isn't still in use as internal processing may still need the allocator. Calls to LockAllocator and UnlockAllocator can be used to keep track of the number of requests that still require processing. The functions in the RequestMemoryAllocator can be called from various threads and may prevent the Streamer from continuing processing. (Similar to the completion callbacks in the requests). It's recommended to spend as little time as possible in these callbacks and defer work to jobs where possible.

Member Function Documentation

◆ Allocate()

virtual RequestMemoryAllocatorResult AZ::IO::IStreamerTypes::RequestMemoryAllocator::Allocate ( u64  minimalSize,
u64  recommendeSize,
size_t  alignment 
)
pure virtual

Allocate memory for a request.

Parameters
minimalSizeThe minimal amount of memory to reserve. More can be reserved, but not less.
recommendedSizeThe recommended amount of memory to reserve. If this size or more is reserved temporary buffers can be avoided.
alignmentThe minimal recommended memory alignment. If the alignment is less than the recommendation it may force the Streamer to create temporary buffers and do extra processing.
Returns
A description of the allocated memory. If allocation fails, return a size of 0 and a null pointer for the address.

Implemented in AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.

◆ LockAllocator()

virtual void AZ::IO::IStreamerTypes::RequestMemoryAllocator::LockAllocator ( )
pure virtual

Called when the Streamer is about to start allocating memory for a request. This will be called multiple times.

Implemented in AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.

◆ Release()

virtual void AZ::IO::IStreamerTypes::RequestMemoryAllocator::Release ( void *  address)
pure virtual

Releases memory previously allocated by Allocate.

Parameters
addressThe address previously provided by Allocate.

Implemented in AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.

◆ UnlockAllocator()

virtual void AZ::IO::IStreamerTypes::RequestMemoryAllocator::UnlockAllocator ( )
pure virtual

Called when the Streamer no longer needs to manage memory for a request. This will be called multiple times. If the number of unlocks matches the number of locks it means the memory allocator is not actively being used by the Streamer.

Implemented in AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.


The documentation for this class was generated from the following file: