An open API service indexing awesome lists of open source software.

https://github.com/hosseinmoein/cougar

Modern C++ Stack and Static based allocators + a Custom Aligned allocator
https://github.com/hosseinmoein/cougar

allocators cache cache-control containers cpp cpp-programming memory-allocation memory-management

Last synced: 9 months ago
JSON representation

Modern C++ Stack and Static based allocators + a Custom Aligned allocator

Awesome Lists containing this project

README

          

![GitHub](https://img.shields.io/github/license/hosseinmoein/DataFrame.svg?color=red&style=popout)
[![C++20](https://img.shields.io/badge/C%2B%2B-20-blue.svg)](https://isocpp.org/std/the-standard )
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/hosseinmoein/DataFrame/graphs/commit-activity)

Allocator Cougar

This repo includes several STL conformant allocators. There are two categories of allocators here:
1. Stack or Static based fixed size allocators. In this category you pre-allocate a fixed size memory block either on the stack or statically. So you can have STL containers that are based on stack memory, for example. One of the side effects of these allocators is to overcome deficiencies in containers like maps and lists where their memory by default is not cache-friendly.
2. Custom Aligned allocator. This allocator allows you to allocate memory on a custom boundary. This way you can take advantage of SIMD instructions and techniques.

Please see the [tester file](test/allocator_tester.cc) for code samples.

This is the complete list of allocators in this repo:

```cpp
// An allocator that allows you to allocate memory for type T on boundary AS.
// The default boundary is system default for type T.
template
AlignedAllocator
```
```cpp
// This allocator pre-allocates memory for MAX_SIZE * sizeof(T) bytes statically.
// It uses best-fit algorithm to find space. Best-fit is a bit slower,
// but it causes considerably less fragmentations
template
StaticBestFitAllocator
```
```cpp
// This allocator pre-allocates memory for MAX_SIZE * sizeof(T) bytes on the stack.
// It uses best-fit algorithm to find space. Best-fit is a bit slower,
// but it causes considerably less fragmentations
template
StackBestFitAllocator
```
```cpp
// This allocator pre-allocates memory for MAX_SIZE * sizeof(T) bytes statically.
// It uses first-fit algorithm to find space. First-fit is faster,
// but it causes more fragmentations
template
StaticFirstFitAllocator
```
```cpp
// This allocator pre-allocates memory for MAX_SIZE * sizeof(T) bytes on the stack.
// It uses first-fit algorithm to find space. First-fit is faster,
// but it causes more fragmentations
template
StackFirstFitAllocator
```