Gnash  0.8.10
Public Types | Public Member Functions
gnash::GC Class Reference

Garbage collector singleton. More...

#include <GC.h>

List of all members.

Public Types

typedef std::map< std::string,
unsigned int > 

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.

Detailed Description

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.

Member Typedef Documentation

typedef std::map<std::string, unsigned int> gnash::GC::CollectablesCount

Constructor & Destructor Documentation

gnash::GC::GC ( GcRoot root)

Create a garbage collector using the given root.

rootThe 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.

Member Function Documentation

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.


  • the object isn't already in this GC list.
  • the object isn't marked as reachable.
  • the object isn't managed by another GC (UNCHECKED)
itemThe 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.

References assert, and _.

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]

Run the collector, if worth it.

References _.

Referenced by gnash::movie_root::reset().

void gnash::GC::runCycle ( )

Run the collection cycle.

Find all reachable collectables, destroy all the others.

The documentation for this class was generated from the following files: