Allocate big things without caring about fragmentation.
Allows allocation of large chunks of memory even if no continuous chunk is available.
Strategy: Allocate smaller chunks, encapsulate the house keeping, expose a convenient interface.
#include <bigalloc.h>
#include <iostream>
int main()
{
const size_t size = 1024 * 1024 * 1024; // something large, you get the point
// Allocation:
BigAlloc<>::Handle big_block = BigAlloc<>::malloc(size);
if(big_block != nullptr)
{
// Writing to memory:
*big_block[128] = 32;
// Reading from memory:
std::cout << *big_block[128];
// Deallocation:
BigAlloc<>::free(big_block);
}
return 0;
}
The software is licensed under the MIT license. See file: LICENSE.
The contribution process is as usual with open source.
- You fork this (or other, forked) repository
- You make your changes
- You open a pull request
- Your pull request is reviewed
- Optional: Changes are requested to the pull request
- You make the neccesary changes (skip this step if 5 wasn't done)
- Optional: Go to step 4
- Your fork is merged
When doing your development and testing I recommend using StackHeap to allocate memory on the stack instead of the heap, in a sequential and deterministic fashion. This makes it trivial to keep track of and visualize the state of the memory. See example: test1.cpp.