libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
GblArenaAllocator Struct Reference

#include <gimbal_arena_allocator.h>

Inheritance diagram for GblArenaAllocator:
GblObject GblBox GblITableVariant GblInstance

Data Fields

union { 
 
   GblArenaAllocatorClass *   pClass 
 
   GblObject   base 
 
};  
 
union { 
 
   GblArenaAllocatorPage *   pActivePage 
 
   GblLinkedListNode   listNode 
 
};  
 
GblContextpCtx
 
size_t pageSize
 
size_t pageAlign
 
size_t allocCount
 
- Data Fields inherited from GblObject
union { 
 
   GblObjectClass *   pClass 
 
   GblBox   base 
 
};  
 
- Data Fields inherited from GblBox
union { 
 
   GblBoxClass *   pClass 
 
   GblInstance   base 
 
};  
 
struct { 
 
   GblArrayMap *   pFields 
 
   volatile uint16_t   refCounter 
 
   uint16_t   contextType: 1 
 
   uint16_t   constructedInPlace: 1 
 
   uint16_t   derivedFlags: 14 
 
private_ 
 
- Data Fields inherited from GblInstance
GblClasspClass
 

Additional Inherited Members

Detailed Description

Arena/zone/region/area-based paged allocator.

GblArenaAllocator is a custom allocator which is useful for when you are allocating a bunch of data dynamically which all has the same shared lifetime. The allocator is created once, then as allocations are requested, it only allocates new memory in per-page incremements rather than for individual allocations. Finally, when you're done, rather than calling delete, you simply destruct the allocator, which frees its pages all at once. This can be SUBSTANTIALLY faster than calling malloc() or new for backing data structures with such allocation patterns.

Note
It's often useful to create the first allocation page as a static buffer somewhere in a source file, so that heap memory isn't even used until it's necessary. Be sure to set the GblArenaAllocatorPage::staticAlloc flag to ensure the allocator does not attempt to free it!
See also
GblArenaAllocatorPage, GblPoolAllocator

Definition at line 92 of file gimbal_arena_allocator.h.

Field Documentation

◆ pClass

GblArenaAllocatorClass* GblArenaAllocator::pClass

Pointer to class/vtable structure.

Definition at line 92 of file gimbal_arena_allocator.h.

◆ base

GblObject GblArenaAllocator::base

Inherited base instance structure.

Definition at line 92 of file gimbal_arena_allocator.h.

◆ pActivePage

GblArenaAllocatorPage* GblArenaAllocator::pActivePage

Active (unfilled) page at list head.

Definition at line 94 of file gimbal_arena_allocator.h.

◆ listNode

GblLinkedListNode GblArenaAllocator::listNode

Linked list node base.

Definition at line 95 of file gimbal_arena_allocator.h.

◆ pCtx

GblContext* GblArenaAllocator::pCtx

Custom context associated with allocator.

Definition at line 97 of file gimbal_arena_allocator.h.

◆ pageSize

size_t GblArenaAllocator::pageSize

Default page size for all new pages.

Definition at line 98 of file gimbal_arena_allocator.h.

◆ pageAlign

size_t GblArenaAllocator::pageAlign

Alignment of each page, also maximum requestable alignment.

Definition at line 99 of file gimbal_arena_allocator.h.

◆ allocCount

size_t GblArenaAllocator::allocCount

Total # of allocations across all pages.

Definition at line 100 of file gimbal_arena_allocator.h.


The documentation for this struct was generated from the following file: