Skip to content

Group memory

Memory management and allocation.

Classes

Type Name
class SparkyStudios::Audio::Amplitude::AmFakeSharedPtr <typename T>
Fake shared pointer.
class SparkyStudios::Audio::Amplitude::AmSharedPtr <class T, Pool>
Shared pointer type.
class SparkyStudios::Audio::Amplitude::DefaultMemoryAllocator
Default memory allocator.
class SparkyStudios::Audio::Amplitude::MemoryAllocator
Memory Allocator Interface.
class SparkyStudios::Audio::Amplitude::MemoryManager
Manages memory allocations inside the engine.
struct SparkyStudios::Audio::Amplitude::MemoryPoolStats
Collects the statistics about the memory allocations for a specific pool.
class SparkyStudios::Audio::Amplitude::ScopedMemoryAllocation
Allocates a block of memory with the given size in the given pool.
struct SparkyStudios::Audio::Amplitude::am_delete <class T, Pool>
Deleter for unique/shared pointers.

Public Types

Type Name
typedef std::unique_ptr< T, am_delete< T, Pool > > AmUniquePtr
Unique pointer type.
enum AmUInt8 eMemoryPoolKind
Available memory pools.

Macros

Type Name
define amMemory [**SparkyStudios::Audio::Amplitude::MemoryManager::GetInstance**](class_sparky_studios_1_1_audio_1_1_amplitude_1_1_memory_manager.md#function-getinstance)()
Shortcut access to the Amplitude's memory manager instance.
define amdelete (_type_, _ptr_) [**ampooldelete**](group__memory.md#define-ampooldelete)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_type\_, \_ptr\_)
Deallocates a memory allocated with amnew amnew.
define amfree (_ptr_) [**ampoolfree**](group__memory.md#define-ampoolfree)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_ptr\_)
Deallocates a block of memory from the default memory pool.
define ammalign (_size_, _alignment_) [**ampoolmalign**](group__memory.md#define-ampoolmalign)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_size\_, \_alignment\_)
Allocates a block of memory from the default memory pool.
define ammalloc (_size_) [**ampoolmalloc**](group__memory.md#define-ampoolmalloc)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_size\_)
Allocates a block of memory from the default memory pool.
define amnew (_type_, ...) [**ampoolnew**](group__memory.md#define-ampoolnew)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_type\_, \_\_VA\_ARGS\_\_)
Allocates memory for a new object in the Default pool using the memory manager.
define ampooldelete (_pool_, _type_, _ptr_) /* multi line expression */
Deallocates a memory allocated with ampoolnew ampoolnew.
define ampoolfree (_pool_, _ptr_) [**amMemory**](group__memory.md#define-ammemory)-&gt;Free(\_pool\_, \_ptr\_)
Deallocates a block of memory from the specified memory pool.
define ampoolmalign (_pool_, _size_, _alignment_) [**amMemory**](group__memory.md#define-ammemory)-&gt;Malign(\_pool\_, \_size\_, \_alignment\_, \_\_FILE\_\_, \_\_LINE\_\_)
Allocates an aligned block of memory from the specified memory pool.
define ampoolmalloc (_pool_, _size_) [**amMemory**](group__memory.md#define-ammemory)-&gt;Malloc(\_pool\_, \_size\_, \_\_FILE\_\_, \_\_LINE\_\_)
Allocates a block of memory from the specified memory pool.
define ampoolnew (_pool_, _type_, ...) new ([**ampoolmalign**](group__memory.md#define-ampoolmalign)(\_pool\_, sizeof(\_type\_), alignof(\_type\_))) \_type\_(\_\_VA\_ARGS\_\_)
Allocates memory for a new object in the given memory pool.
define ampoolrealign (_pool_, _ptr_, _size_, _alignment_) [**amMemory**](group__memory.md#define-ammemory)-&gt;Realign(\_pool\_, \_ptr\_, \_size\_, \_alignment\_, \_\_FILE\_\_, \_\_LINE\_\_)
Reallocates an aligned block of memory from the specified memory pool.
define ampoolrealloc (_pool_, _ptr_, _size_) [**amMemory**](group__memory.md#define-ammemory)-&gt;Realloc(\_pool\_, \_ptr\_, \_size\_, \_\_FILE\_\_, \_\_LINE\_\_)
Reallocates a block of memory from the specified memory pool.
define ampoolshared (__pool__, __type__, ...) AmSharedPtr&lt;\_\_type\_\_, \_\_pool\_\_&gt;::Make(\_\_VA\_ARGS\_\_)
Creates a shared pointer to an object allocated in a specific memory pool.
define ampoolunique (__pool__, __type__, ...) AmUniquePtr&lt;\_\_type\_\_, \_\_pool\_\_&gt;([**ampoolnew**](group__memory.md#define-ampoolnew)(\_\_pool\_\_, \_\_type\_\_, \_\_VA\_ARGS\_\_))
Creates a unique pointer to an object allocated in a specific memory pool.
define amrealign (_ptr_, _size_, _alignment_) [**ampoolrealign**](group__memory.md#define-ampoolrealign)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_ptr\_, \_size\_, \_alignment\_)
Reallocates an aligned block of memory from the default memory pool.
define amrealloc (_ptr_, _size_) [**ampoolrealloc**](group__memory.md#define-ampoolrealloc)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_ptr\_, \_size\_)
Reallocates a block of memory from the default memory pool.
define amshared (_type_, ...) [**ampoolshared**](group__memory.md#define-ampoolshared)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_type\_, \_\_VA\_ARGS\_\_)
Creates a shared pointer to an object allocated in the default memory pool.
define amunique (_type_, ...) [**ampoolunique**](group__memory.md#define-ampoolunique)(SparkyStudios::Audio::Amplitude::eMemoryPoolKind\_Default, \_type\_, \_\_VA\_ARGS\_\_)
Creates a unique pointer to an object allocated in the default memory pool.

Public Types Documentation

AmUniquePtr

Unique pointer type.

using SparkyStudios::Audio::Amplitude::AmUniquePtr = std::unique_ptr<T, am_delete<T, Pool>>;

Template parameters:

  • T The type of the pointer to allocate.
  • Pool The memory pool to allocate the pointer from.
eMemoryPoolKind

Available memory pools.

enum eMemoryPoolKind {
    eMemoryPoolKind_Engine,
    eMemoryPoolKind_Amplimix,
    eMemoryPoolKind_SoundData,
    eMemoryPoolKind_Filtering,
    eMemoryPoolKind_Codec,
    eMemoryPoolKind_IO,
    eMemoryPoolKind_Default,
    eMemoryPoolKind_COUNT
};

Macro Definition Documentation

amMemory

Shortcut access to the Amplitude's memory manager instance.

#define amMemory `SparkyStudios::Audio::Amplitude::MemoryManager::GetInstance ()`
amdelete

Deallocates a memory allocated with amnew amnew.

#define amdelete (
    _type_,
    _ptr_
) `ampooldelete ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _type_, _ptr_)`

This will call the object's destructor before the memory is freed.

Parameters:

  • _type_ The type of the object to deallocate.
  • _ptr_ The pointer to the object to deallocate.

See also: amnew amnew

amfree

Deallocates a block of memory from the default memory pool.

#define amfree (
    _ptr_
) `ampoolfree ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _ptr_)`

Parameters:

  • _ptr_ The pointer to deallocate.

See also: ampoolfree ampoolfree

ammalign

Allocates a block of memory from the default memory pool.

#define ammalign (
    _size_,
    _alignment_
) `ampoolmalign ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _size_, _alignment_)`

Parameters:

  • _size_ The size of the memory to allocate.
  • _alignment_ The alignment of the memory to allocate.

See also: ampoolmalign ampoolmalign

ammalloc

Allocates a block of memory from the default memory pool.

#define ammalloc (
    _size_
) `ampoolmalloc ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _size_)`

Parameters:

  • _size_ The size of the memory to allocate.

See also: ampoolmalloc ampoolmalloc

amnew

Allocates memory for a new object in the Default pool using the memory manager.

#define amnew (
    _type_,
    ...
) `ampoolnew ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _type_, __VA_ARGS__)`

This will create a new memory allocation in the Default pool. The allocated memory will be freed when the object is destroyed using amdelete amdelete.

Parameters:

  • _type_ The type of the object to allocate.
  • ... Additional arguments to pass to the constructor of the object.

See also: amdelete amdelete

ampooldelete

Deallocates a memory allocated with ampoolnew ampoolnew.

#define ampooldelete (
    _pool_,
    _type_,
    _ptr_
) `/* multi line expression */`

This will call the object's destructor before to free the memory.

Parameters:

  • _pool_ The memory pool to deallocate from.
  • _type_ The type of the object to deallocate.
  • _ptr_ The pointer to the object to deallocate.

See also: ampoolnew ampoolnew

ampoolfree

Deallocates a block of memory from the specified memory pool.

#define ampoolfree (
    _pool_,
    _ptr_
) `amMemory ->Free(_pool_, _ptr_)`

Parameters:

  • _pool_ The memory pool to deallocate from.
  • _ptr_ The pointer to deallocate.
ampoolmalign

Allocates an aligned block of memory from the specified memory pool.

#define ampoolmalign (
    _pool_,
    _size_,
    _alignment_
) `amMemory ->Malign(_pool_, _size_, _alignment_, __FILE__, __LINE__)`

Parameters:

  • _pool_ The memory pool to deallocate from.
  • _size_ The size of the memory to allocate.
  • _alignment_ The alignment of the memory to allocate.
ampoolmalloc

Allocates a block of memory from the specified memory pool.

#define ampoolmalloc (
    _pool_,
    _size_
) `amMemory ->Malloc(_pool_, _size_, __FILE__, __LINE__)`

Parameters:

  • _pool_ The memory pool to allocate from.
  • _size_ The size of the memory to allocate.
ampoolnew

Allocates memory for a new object in the given memory pool.

#define ampoolnew (
    _pool_,
    _type_,
    ...
) `new ( ampoolmalign (_pool_, sizeof(_type_), alignof(_type_))) _type_(__VA_ARGS__)`

This will create a new memory allocation in the given pool. The allocated memory will be freed when the object is destroyed using ampooldelete ampooldelete.

Parameters:

  • _pool_ The memory pool to allocate from.
  • _type_ The type of the object to allocate.
  • ... Additional arguments to pass to the constructor of the object.

See also: ampooldelete ampooldelete

ampoolrealign

Reallocates an aligned block of memory from the specified memory pool.

#define ampoolrealign (
    _pool_,
    _ptr_,
    _size_,
    _alignment_
) `amMemory ->Realign(_pool_, _ptr_, _size_, _alignment_, __FILE__, __LINE__)`

Parameters:

  • _pool_ The memory pool to reallocate from. Should be the same as the one used to allocate the memory.
  • _ptr_ The pointer to reallocate.
  • _size_ The new size of the memory.
  • _alignment_ The alignment of the memory to reallocate.
ampoolrealloc

Reallocates a block of memory from the specified memory pool.

#define ampoolrealloc (
    _pool_,
    _ptr_,
    _size_
) `amMemory ->Realloc(_pool_, _ptr_, _size_, __FILE__, __LINE__)`

Parameters:

  • _pool_ The memory pool to reallocate from. Should be the same as the one used to allocate the memory.
  • _ptr_ The pointer to reallocate.
  • _size_ The new size of the memory.
ampoolshared

Creates a shared pointer to an object allocated in a specific memory pool.

#define ampoolshared (
    __pool__,
    __type__,
    ...
) `AmSharedPtr<__type__, __pool__>::Make(__VA_ARGS__)`

This will create a new memory allocation in the specified pool. The allocated memory will be freed when the last shared pointer to the object is destroyed.

Parameters:

  • __pool__ The memory pool to allocate the object in.
  • __type__ The type of the object to allocate.
  • ... Additional arguments to pass to the constructor of the object.

See also: amdelete amdelete

ampoolunique

Creates a unique pointer to an object allocated in a specific memory pool.

#define ampoolunique (
    __pool__,
    __type__,
    ...
) `AmUniquePtr<__type__, __pool__>( ampoolnew (__pool__, __type__, __VA_ARGS__))`

This will create a new memory allocation in the specified pool. The allocated memory will be freed when the object is destroyed using amdelete amdelete.

Parameters:

  • __pool__ The memory pool to allocate the object in.
  • __type__ The type of the object to allocate.
  • ... Additional arguments to pass to the constructor of the object.

See also: amdelete amdelete

amrealign

Reallocates an aligned block of memory from the default memory pool.

#define amrealign (
    _ptr_,
    _size_,
    _alignment_
) `ampoolrealign ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _ptr_, _size_, _alignment_)`

Parameters:

  • _ptr_ The pointer to reallocate.
  • _size_ The new size of the memory.
  • _alignment_ The alignment of the memory to reallocate.

See also: ampoolrealign ampoolrealign

amrealloc

Reallocates a block of memory from the default memory pool.

#define amrealloc (
    _ptr_,
    _size_
) `ampoolrealloc ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _ptr_, _size_)`

Parameters:

  • _ptr_ The pointer to reallocate.
  • _size_ The new size of the memory.

See also: ampoolrealloc ampoolrealloc

amshared

Creates a shared pointer to an object allocated in the default memory pool.

#define amshared (
    _type_,
    ...
) `ampoolshared ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _type_, __VA_ARGS__)`

This will create a new memory allocation in the default pool. The allocated memory will be freed when the last shared pointer to the object is destroyed.

Parameters:

  • __type__ The type of the object to allocate.
  • ... Additional arguments to pass to the constructor of the object.

See also: amdelete amdelete

amunique

Creates a unique pointer to an object allocated in the default memory pool.

#define amunique (
    _type_,
    ...
) `ampoolunique ( SparkyStudios::Audio::Amplitude::eMemoryPoolKind_Default , _type_, __VA_ARGS__)`

This will create a new memory allocation in the default pool. The allocated memory will be freed when the object is destroyed using amdelete amdelete.

Parameters:

  • __type__ The type of the object to allocate.
  • ... Additional arguments to pass to the constructor of the object.

See also: amdelete amdelete