|
CppGC
1.01
|
#include <gc.h>
Public Member Functions | |
| MemoryAllocator (size_t gcStartThreshold=1024 *1024, size_t gcAutoStartThreshold=(size_t)-1) | |
| ~MemoryAllocator () | |
| void | _registerRoot (Root *root) |
| void | _unregisterRoot (Root *root) |
| void | _mark (Object *obj) |
| void | _mark (Object **refs, size_t nRefs) |
| void * | _allocate (size_t size) |
| void | _gc () |
| void | _allowGC () |
Static Public Member Functions | |
| static MemoryAllocator * | getCurrent () |
| static void * | allocate (size_t size) |
| static void | mark (Object *obj) |
| static void | mark (Object **refs, size_t nRefs) |
| static void | registerRoot (Root *root) |
| static void | unregisterRoot (Root *root) |
| static void | gc () |
| static void | allowGC () |
Friends | |
| class | Object |
Memory allocator class with implicit memory deallocation (garbage collector). Each thread should have its own allocator. So each thread is allocating and deallocating only its own objects. But it is possible to refer object created by some global allocator, taken in account that this objects will not be protected from GC.
| GC::MemoryAllocator::MemoryAllocator | ( | size_t | gcStartThreshold = 1024 *1024, |
| size_t | gcAutoStartThreshold = (size_t)-1 |
||
| ) |
Create instance of memory allocator
| gcStartThreshold | total size of objects allocated since last GC after which allowGC() method initiates garbage collection |
| gcAutoStartThreshold | total size of objects allocated since last GC after which garbage collection is automatically started. Please notice that all used objects should be protected from GC in this case by registering their roots. |
Deallocate all objects create by GC.
| static void* GC::MemoryAllocator::allocate | ( | size_t | size | ) | [static] |
| static void GC::MemoryAllocator::allowGC | ( | ) | [static] |
Start garbage collection if number of allocated objects since last GC exceeds StartThreshold
| static void GC::MemoryAllocator::gc | ( | ) | [static] |
Explicitly starts garbage collection.
| static MemoryAllocator* GC::MemoryAllocator::getCurrent | ( | ) | [static] |
Get allocator for the current thread. Each thread should have its own allocator.
| static void GC::MemoryAllocator::mark | ( | Object * | obj | ) | [static] |
Mark object as reachable and recursively mark all references objects
| obj | marked objects (may be NULL) |
Referenced by GC::Ref< ObjectArray< T > >::Ref().
| static void GC::MemoryAllocator::mark | ( | Object ** | refs, |
| size_t | nRefs | ||
| ) | [static] |
Mark array of objects.
| refs | pointer to array of references |
| nRefs | number of references |
| static void GC::MemoryAllocator::registerRoot | ( | Root * | root | ) | [static] |
Register root object. Registering root protects it and all referenced objects from GC.
Referenced by GC::Root::Root().
| static void GC::MemoryAllocator::unregisterRoot | ( | Root * | root | ) | [static] |
Unregister root object. Make this object tree available for GC.
Referenced by GC::Root::~Root().
1.7.6.1