RepositoryC++USUnited States
hosseinmoein

hosseinmoein/Cougar

Stack and Static based allocators + a Custom Aligned allocator in modern C++

108stars
5forks
0issues
6views

GitHub C++20 Maintenance

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 for code samples.

This is the complete list of allocators in this repo:

// An allocator that allows you to allocate memory for type T on boundary AS.
// The default boundary is system default for type T.
template<typename T, std::size_t AS = 0>
AlignedAllocator
// 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<typename T, std::size_t MAX_SIZE>
StaticBestFitAllocator
// 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<typename T, std::size_t MAX_SIZE>
StackBestFitAllocator
// 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<typename T, std::size_t MAX_SIZE>
StaticFirstFitAllocator
// 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<typename T, std::size_t MAX_SIZE>
StackFirstFitAllocator

Similar Projects

Discover other similar projects and AI models.

RepositoryC++
dragonflydb/dragonfly

A modern replacement for Redis and Memcached

32.0k
Nov 28, 2026
RepositoryC++
rapidsai/rmm

NVIDIA RMM is a library for allocating and managing GPU memory in C++ and Python.

745
Nov 27, 2026
RepositoryC
bdwgc/bdwgc

The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (bdwgc, also known as bdw-gc, boehm-gc, libgc)

3.6k
Dec 1, 2026
RepositoryPython
practical-tutorials/project-based-learning

Curated list of project-based tutorials

290.9k
Nov 30, 2026
RepositoryJavaScript
CyC2018/CS-Notes

:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计

186.6k
Nov 27, 2026
RepositoryGo
kubernetes/kubernetes

Production-Grade Container Scheduling and Management

129.4k
Nov 26, 2026
RepositoryMarkdown
DigitalPlatDev/FreeDomain

Free domain registration and practical DNS learning resources for everyone.

209.9k
Aug 12, 2026
Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...

♥0
157.6M
Jun 1, 2026
RepositoryC++
tensorflow/tensorflow

An Open Source Machine Learning Framework for Everyone

201.9k
Dec 1, 2026