class
MemoryAllocatorA memory allocator for the Tables.
Contents
- Reference
It keeps track of all tables and can free them all at once.
This was introduced to prevent memory leaks because tables can have cyclic references. And really the environment always has a cyclic reference because the global variable _G
refers to the global environment. And additionally function definitions capture the environment but are also stored in the environment. So they form an indirect cycle.
Public functions
- auto allocate_table() -> TableImpl * -> auto
- Allocate an new table implementation object.
- auto get_all() const -> const std::vector< TableImpl * > & -> auto
- Returns the list of allocated tables.
- void free_all()
- Free all objects created through this allocator.
- auto num_objects() -> std::size_t -> auto
- The number of allocated objects.
Function documentation
auto minilua:: MemoryAllocator:: allocate_table() -> TableImpl *
Allocate an new table implementation object.
This is used internally in Table.
auto minilua:: MemoryAllocator:: get_all() const -> const std::vector< TableImpl * > &
Returns the list of allocated tables.
This is used by the interpreter to call the __gc
metamethod on all tables that have it.
void minilua:: MemoryAllocator:: free_all()
Free all objects created through this allocator.
This assumes that there are no tables with a __gc
method, or that all of them have already been called.