Gnash
0.8.10
|
Garbage collector singleton. More...
#include <GC.h>
Public Types | |
typedef std::map< std::string, unsigned int > | CollectablesCount |
Public Member Functions | |
GC (GcRoot &root) | |
Create a garbage collector using the given root. | |
~GC () | |
Destroy the collector, releasing all collectables. | |
void | addCollectable (const GcResource *item) |
Add an object to the list of managed collectables. | |
void | fuzzyCollect () |
Run the collector, if worth it. | |
void | runCycle () |
Run the collection cycle. | |
void | countCollectables (CollectablesCount &count) const |
Count collectables. |
Garbage collector singleton.
Instances of this class manage a list of heap pointers (collectables), deleting them when no more needed/reachable.
Their reachability is detected starting from a root, which in turn marks all reachable resources.
typedef std::map<std::string, unsigned int> gnash::GC::CollectablesCount |
gnash::GC::GC | ( | GcRoot & | root | ) |
Create a garbage collector using the given root.
root | The top level of the GC, which takes care of marking all further resources. |
gnash::GC::~GC | ( | ) |
Destroy the collector, releasing all collectables.
References gnash::key::i, and gnash::key::e.
void gnash::GC::addCollectable | ( | const GcResource * | item | ) | [inline] |
Add an object to the list of managed collectables.
The given object is expected not to be already in the list. Failing to do so would just decrease performances but might not be a problem. Anyway, an assertion will fail if adding an object twice.
PRECONDITIONS:
item | The item to be managed by this collector. Can't be NULL. The caller gives up ownerhip of it, which will only be deleted by this GC. |
Referenced by gnash::GcResource::GcResource().
void gnash::GC::countCollectables | ( | CollectablesCount & | count | ) | const |
Count collectables.
References gnash::key::i, gnash::key::e, and gnash::typeName().
void gnash::GC::fuzzyCollect | ( | ) | [inline] |
void gnash::GC::runCycle | ( | ) |
Run the collection cycle.
Find all reachable collectables, destroy all the others.