All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kzc_memory_pooled.h File Reference

Pooled memory manager. More...

Functions

KANZI_API kzsError kzcMemoryManagerCreatePooledManager (const struct KzcMemoryManager *parentManager, kzUint poolCount, kzSizeT poolSize, struct KzcMemoryManager **out_manager)
 Creates a new pooled memory manager, which allocates the memory from preallocated memory pools. More...
 
KANZI_API kzsError kzcMemoryDump (const struct KzcMemoryManager *memoryManager, kzBool memoryMap, kzBool sortBySize)
 Dumps the memory content to the log using the KZS_LOG_LEVEL_INFO log level. More...
 
KANZI_API kzsError kzcMemoryPrintDebugAllocations (const struct KzcMemoryManager *memoryManager)
 Logs all active memory allocations and their descriptions allocated with the given memory manager using the KZS_LOG_LEVEL_DETAIL log level. More...
 
KANZI_API kzSizeT kzcMemoryPooledGetMaximumAvailableSize (const struct KzcMemoryManager *memoryManager)
 Gets the maximum available block size of a pooled memory manager. More...
 

Detailed Description

Pooled memory manager.

The pooled memory manager allocates memory from a constant-sized preallocated memory pools. This manager type tries to minimize memory fragmentation and is suitable for most common use cases. However, it is not intended for real-time memory allocation.

This memory manager will not allocate more memory when there is no more free space in the memory pools, instead it will return KZS_ERROR_OUT_OF_MEMORY error.

Copyright 2008-2020 by Rightware. All rights reserved.

Function Documentation

KANZI_API kzsError kzcMemoryManagerCreatePooledManager ( const struct KzcMemoryManager parentManager,
kzUint  poolCount,
kzSizeT  poolSize,
struct KzcMemoryManager **  out_manager 
)

Creates a new pooled memory manager, which allocates the memory from preallocated memory pools.

This memory manager will not allocate more memory when there is no more free space in the memory pools, instead it will return KZS_ERROR_OUT_OF_MEMORY error.

Parameters
parentManagerA valid memory manager that is used for allocating the memory pools. This could be e.g. a system memory manager (see kzc_memory_system.h).
poolCountNumber of memory pools.
poolSizeSize of each memory pool.
out_managerA pointer that is set to point to the new pooled memory manager on success.
Returns
KZS_SUCCESS on success.
KANZI_API kzsError kzcMemoryDump ( const struct KzcMemoryManager memoryManager,
kzBool  memoryMap,
kzBool  sortBySize 
)

Dumps the memory content to the log using the KZS_LOG_LEVEL_INFO log level.

This function is only available for the pooled memory manager.

Parameters
memoryManagerThe memory manager which contents to print.
memoryMapIf KZ_TRUE, prints out offsets of each block in a pool.
sortBySizeIf KZ_TRUE, all memory allocations will be listed from the smallest to largest. Otherwise, the order is the order in memory.
Returns
KZS_ERROR_ILLEGAL_ARGUMENT if the memory manager is not a pooled memory manager, KZS_SUCCESS on success.
KANZI_API kzsError kzcMemoryPrintDebugAllocations ( const struct KzcMemoryManager memoryManager)

Logs all active memory allocations and their descriptions allocated with the given memory manager using the KZS_LOG_LEVEL_DETAIL log level.

This function is only available for the pooled memory manager.

Parameters
memoryManagerThe memory manager which contents to print.
Returns
KZS_ERROR_ILLEGAL_ARGUMENT if the memory manager is not a pooled memory manager, KZS_SUCCESS on success.
KANZI_API kzSizeT kzcMemoryPooledGetMaximumAvailableSize ( const struct KzcMemoryManager memoryManager)

Gets the maximum available block size of a pooled memory manager.