CookMem 1.6.0
A C++ memory context / allocator
Loading...
Searching...
No Matches
cookmem Namespace Reference

Classes

class  MemContextProvider
class  TLSContextProvider
class  TLSContextScope
class  Allocator
class  MemArena
class  FixedArena
class  CachedArena
class  PtrAVLTree
class  CircularList
class  MemContext
struct  SimpleMemContainer
class  SimpleMemContext
struct  CachedMemContainer
class  CachedMemContext
class  Exception
class  MemLogger
class  NoActionMemLogger
struct  MemStatistics
class  StatsLogger
class  MallocArena
class  MemResource
class  MmapArena
class  MemPool
class  PtrRBNode
class  RedBlackTree

Typedefs

typedef RedBlackTree< PtrRBNode > PtrRBTree

Enumerations

enum  MemError_et { MEM_ERROR_GENERAL , MEM_ERROR_ASSERT , MEM_ERROR_DOUBLE_FREE , MEM_ERROR_PADDING }
enum  MemAllocType_et {
  MEM_ALLOC_NONE , MEM_ALLOC_SMALL , MEM_ALLOC_TREE , MEM_ALLOC_DV ,
  MEM_ALLOC_ARENA , MEM_ALLOC_BIG , MEM_ALLOC_COUNT
}

Variables

const std::size_t ALLOCATION_ALIGNMENT = sizeof (std::size_t) * 2
const std::size_t DEFAULT_TRIM_EMPTY_SEGMENTS_INTERVAL = 4095
const std::size_t DEFAULT_IMMEDIATE_RELEASE_THRESHOLD = 256 * 1024
const std::size_t DEFAULT_MIN_SEGMENT_SIZE = 65536
const std::uint8_t DEFAULT_PADDING_SIZE = 0
const std::uint8_t MAX_PADDING_SIZE = 8
const char DEFAULT_PADDING_BYTE = '\xcd'

Detailed Description

All CookMem classes, functions and constants are in this namespace.

Typedef Documentation

◆ PtrRBTree

The red-black tree used for the large chunk bins of MemPool and for CachedArena by default.

Enumeration Type Documentation

◆ MemAllocType_et

How an allocation was satisfied. StatsLogger counts allocations by type.

Enumerator
MEM_ALLOC_NONE 

No allocation

MEM_ALLOC_SMALL 

Small allocation using small bins

MEM_ALLOC_TREE 

Large allocation using tree bins

MEM_ALLOC_DV 

Designated victim allocation

MEM_ALLOC_ARENA 

Allocation obtained from a new arena segment

MEM_ALLOC_BIG 

Big allocation

MEM_ALLOC_COUNT 

Simply used to count the number of alloc types. All new types should be added before this one.

◆ MemError_et

The type of a memory error reported by Exception.

Enumerator
MEM_ERROR_GENERAL 

general error

MEM_ERROR_ASSERT 

assertion failure (COOKMEM_DEBUG builds only)

MEM_ERROR_DOUBLE_FREE 

freeing an already free pointer

MEM_ERROR_PADDING 

padding bytes after an allocation were overwritten

Variable Documentation

◆ ALLOCATION_ALIGNMENT

const std::size_t cookmem::ALLOCATION_ALIGNMENT = sizeof (std::size_t) * 2

The alignment of every pointer returned by allocate () of a memory context: twice the size of std::size_t, which is 16 bytes on 64-bit platforms and 8 bytes on 32-bit platforms. Use allocateAligned () for a larger alignment.

◆ DEFAULT_IMMEDIATE_RELEASE_THRESHOLD

const std::size_t cookmem::DEFAULT_IMMEDIATE_RELEASE_THRESHOLD = 256 * 1024

The default allocation size at which a freed allocation releases its own segment right away (see MemContext::setImmediateReleaseThreshold ()).

◆ DEFAULT_MIN_SEGMENT_SIZE

const std::size_t cookmem::DEFAULT_MIN_SEGMENT_SIZE = 65536

Default minimum memory segment size.

It should be noted that this value needs to be a multiple of 16.

◆ DEFAULT_PADDING_BYTE

const char cookmem::DEFAULT_PADDING_BYTE = '\xcd'

Default padding byte for strict bounds checking.

◆ DEFAULT_PADDING_SIZE

const std::uint8_t cookmem::DEFAULT_PADDING_SIZE = 0

Default number of padding bytes checked after each allocation.

◆ DEFAULT_TRIM_EMPTY_SEGMENTS_INTERVAL

const std::size_t cookmem::DEFAULT_TRIM_EMPTY_SEGMENTS_INTERVAL = 4095

The number of deallocations between automatic empty-segment trimming passes.

◆ MAX_PADDING_SIZE

const std::uint8_t cookmem::MAX_PADDING_SIZE = 8

Maximum number of padding bytes checked after each allocation.