Skip to content

CPPShift MemoryPool v2

Choose a tag to compare

@LessComplexity LessComplexity released this 30 Mar 14:59
· 12 commits to main since this release

CPPShift::Memory::MemoryPoolManager no longer present.
Right now the MemoryPool object holds all the functions to handle the memory pool data structure.

  • Create a memory pool using auto mp = new CPPShift::Memory::MemoryPool(size); or auto mp = CPPShift::Memory::MemoryPool(size);
  • Allocation, re-allocation and de-allocation are now new (mp) Type[size];, mp->reallocate<Type>(pointer, size); and mp->free(pointer) respectively.
  • Allocate & re-allocate now have two modes: templated and general -> mp->allocate<Type>(size); or (Type*) mp->allocate(size * sizeof(Type)), and mp->reallocate<Type>(pinter, size) or (Type*) mp->reallocate(pinter, size * sizeof(Type)). These 2 approaches to each function are actually the same.
  • Manage scopes using mp->startScope() & mp->endScope()
  • Got slightly better performance (from a maximum of 22 time better to a maximum of 24 times better depending on OS & compiler)