Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/alloc/ListGC.h>
Classes | |
class | block_t |
Public Member Functions | |
ListGC (GCManager &m, int limit=1024) | |
~ListGC () | |
void * | allocate (t::size size) override |
void | runGC () override |
bool | mark (void *data, t::size size) override |
void | disable () override |
void | enable () override |
void | clean () override |
Public Member Functions inherited from AbstractGC | |
AbstractGC (GCManager &m) | |
virtual | ~AbstractGC () |
virtual void | free (void *block) |
template<class T > | |
void * | alloc () |
Additional Inherited Members | |
Protected Attributes inherited from AbstractGC | |
GCManager & | manager |
A simple garbage collector allocator from the main heap but keep trace of the allocated objects to release them automatically.
The GC is automatically triggered when the difference of the number of allocated object since the last GC cycle is bigger than a configuration limit.
Build a list GC.
m | Current garbage collection manager. |
limit | Limit triggering garbage collection. |
~ListGC | ( | ) |
References ListGC::clean().
Allocate a block of the given size. This function is often used this way:
size | Size of the memory to allocate. |
Implements AbstractGC.
References ListGC::block_t::alloc(), elm::io::p(), and ListGC::runGC().
|
overridevirtual |
Clean the memory allocated in the garbage collector and reset it to its initial state.
Implements AbstractGC.
References GCManager::clean(), AbstractGC::manager, and elm::io::p().
Referenced by ListGC::~ListGC().
|
overridevirtual |
Disable the automatic run of the garbage collection.
Implements AbstractGC.
|
overridevirtual |
Disable the automatic run of the garbage collection. May trigger immediately a GC cycle.
Implements AbstractGC.
References ListGC::runGC().
Record the given block as alive. This function can only be called during a garbage collection cycle.
data | Pointer to the alive memory block. |
size | Size of the block. |
Implements AbstractGC.
References ListGC::block_t::block().
|
overridevirtual |
Called to start, by hand, a garbage collection cycle. Depending on the underlying implementation, this function may be automatically called by the garbage collector itself. Notice that during a garbage collection cycle, any call to allocate() or alloc() is forbidden.
Implements AbstractGC.
References GCManager::clean(), GCManager::collect(), AbstractGC::manager, and elm::io::p().
Referenced by ListGC::allocate(), and ListGC::enable().