Skip to content
A series of memory utilities, such as memory pools, for a C++11 application.
C++ C
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Allocator
Container
Pool
Utility
ForwardDeclarations.h
ICMemory.h
LICENSE
README.md

README.md

ICMemory

A collection of efficient memory allocators and pools. This provides four allocator types:

  • BuddyAllocator: A general allocator which efficiently handles external fragmentation by splitting blocks into "buddies". This is primarily for large allocations.
  • LinearAllocator: A very fast general allocator which allocates from a linear buffer, and deallocates the entire buffer when Reset() is called. This is primarily for large numbers of short lived allocations.
  • BlockAllocator: A very fast allocator for fixed sized blocks. This is primarily used by ObjectPool.
  • SmallObjectAllocator: A very fast allocator for small objects. This is similar to BlockAllocator but has several block sizes. This is primarily used for small objects that aren't suitable for pooling.

Paged versions of some of the allocators are also available, which scale the allocator size if it has run out of space.

For more information on the different allocator types, see the class documentation in the headers.

Usage

Allocating using the allocators is simply a case of using one of the various factory methods provided.

IC::LinearAllocator linearAllocator(1024);
auto allocated = IC::MakeUnique<int>(linearAllocator);

Allocating from a pool is just as simple:

IC::ObjectPool<int> objectPool(128);
auto allocated = objectPool.Create();

Links

You can’t perform that action at this time.