/cookmem

A C++ memory context

Primary LanguageCApache License 2.0Apache-2.0

CookMem {#mainpage}

Build StatuscodecovApache License, Version 2.0

CookMem is a memory context / allocator written in C++11 that can be easily and quickly cleaned up by freeing the segments, rather than doing individual frees.

Unlike projects such as nedmalloc which is intended to replace malloc / free in multi-threaded applications, this project focuses on the single-thread performance. It is intended to be used within a thread in an MPP process, such that it would not have to pay for the cost of synchronization for tiny allocations / deallocations.

Additionally, cookmem separates out the logic for obtaining large segments of memory, to allow users easily creating their flavor of the memory context for their specific needs.

The algorithms and some code used here are based on dlmalloc. I basically took the pain to understand dlmalloc and rewrote the logics in C++. Some key calculations though are kept the same as dlmalloc since there are no points to reinvent wheels.

Since I have never learnt Red-black tree, which dlmalloc uses. AVL tree is used instead. There can be some minor performance trade offs. Maybe one day I will learn the RB-tree and check the difference ;)