Skip to content

jurgen-kluft/csuperalloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A (virtual) memory allocator library

A library that provides cross-platform usage of a virtual memory allocator.

Note: See ccode on how to generate the buildfiles.

If you like my work and want to support me. Please consider to buy me a coffee!

Superalloc

Currently this allocator, called 'superalloc', is implemented in C++ and is around 1200 lines of code for the core. This allocator is very configurable and all book-keeping data is outside of the managed memory making it very suitable for different kind of memory (read-only, GPU etc..).

It only uses the following data structures:

  • plain old c style arrays
  • binmap; 4 layer bit array (maximum of 2^20 items)
  • doubly linked list
class valloc_t
{
public:
      void* allocate(u32 size, u32 align);
      u32   deallocate(void*);
      
      // You can tag an allocation, very useful for attaching debugging info to an allocation or
      // using it as a CPU/GPU handle.
      void  set_tag(void*, u32);
      u32   get_tag(void*);
      u32   get_size(void*);
};

Note: Benchmarks are still to be done.
Note: Unittest contains a test called stress test that executes 500.000 operations (allocation / deallocation)

WIP

Some things missing:

  • not multi-thread safe (yet)
  • cached chunks are not limited so nothing is released back in terms of unused physical pages.

Releases

No releases published

Packages

No packages published

Languages