Library
Library dependency tower for xo-alloc:
Install instructions here
Components
Abstraction tower for xo-alloc components:
IAlloc Allocator interface.
- Object
Root Object Interface for types participating in garbage collection
- GC
Incremental compacting garbage collector.
- ListAlloc
Auto-expanding allocator. Contains a collection of ArenaAllocs
- ArenaAlloc
Arena allocator (a.k.a bump allocator).
- Object
Interface for types that participate in garbage collection
- Forwarding1
Forwarding pointer. Supports the Object interface; used internally by GC during evacuation.
Key Points
Allocators can be reset, but do not support freeing of individual allocs.
GC works with types that implement auxiliary GC-support methods. Such types must inherit Object.
A region may uses multiple arenas, but because of allocation activity since the last GC. If necessary, GC will allocate a new to-space with a single arena that’s large enough to accomodate all objects that might survive from a from-space that has acquired multiple arenas. Intent is to scale up to find application’s working set size, then stabilize
Components
Allocators
Inheritance
allocators
Composition
allocator composition
Each ListAlloc composes like this:
ListAlloc composition
Here a1 and a2 are full, while a0 can still allocate memory.
Objects
objects
![class IAlloc {
+ alloc()
+ alloc_gc_copy()
+ checkpoint()
+ clear()
}
class ArenaAlloc {
+ free_ptr()
- lo_ : byte*
- checkpoint_ : byte*
- limit_ : byte*
}
IAlloc <|-- ArenaAlloc
class ListAlloc {
+ expand()
+ free_ptr()
- start_z_
- hd_
- full_l_
}
IAlloc <|-- ListAlloc
class GC {
+ add_gc_root()
+ request_gc()
+ gc_statistics()
- gc_root_v_[] : Object**
- nursery_[2] : ListAlloc*
- tenured_[2] : ListAlloc*
}
IAlloc <|-- GC](_images/plantuml-3bd73d17da246be02ca3193dd420693185b70e4d.png)
![object gc<<GC>>
gc : nursery[from] = n0
gc : nursery[to] = n1
gc : tenured[from] = t0
gc : tenured[to] = t1
object n0<<ListAlloc>>
object n1<<ListAlloc>>
object t0<<ListAlloc>>
object t1<<ListAlloc>>
gc o-- n0
gc o-- n1
gc o-- t0
gc o-- t1](_images/plantuml-665547522f7b5766d4a512b70e683d3a0f0b0ee8.png)

