Pooled memory manager. More...
#include "kzc_memory_common.h"
#include <system/kzs_types.h>
#include <system/debug/kzs_error.h>
#include <system/kzs_header.h>
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... | |
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.
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.
parentManager | A 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). |
poolCount | Number of memory pools. |
poolSize | Size of each memory pool. |
out_manager | A pointer that is set to point to the new pooled memory manager 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.
memoryManager | The memory manager which contents to print. |
memoryMap | If KZ_TRUE, prints out offsets of each block in a pool. |
sortBySize | If KZ_TRUE, all memory allocations will be listed from the smallest to largest. Otherwise, the order is the order in memory. |
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.
memoryManager | The memory manager which contents to print. |
KANZI_API kzSizeT kzcMemoryPooledGetMaximumAvailableSize | ( | const struct KzcMemoryManager * | memoryManager | ) |
Gets the maximum available block size of a pooled memory manager.