Public Types | Public Member Functions | Static Public Member Functions

gnash::GC Class Reference

Garbage collector singleton. More...

#include <GC.h>

Collaboration diagram for gnash::GC:
Collaboration graph

List of all members.

Public Types

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

Public Member Functions

void addCollectable (const GcResource *item)
 Add an heap 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.

Static Public Member Functions

static GCinit (GcRoot &r)
 Init the singleton instance using the given GcRoot.
static void cleanup ()
static GCget ()
 Get the singleton.

Detailed Description

Garbage collector singleton.

Instances of this class ( you' only use one, the singleton ) manage a list of heap pointers (collectables) deleting them when no more needed/reachable.

Reachability of them is detected starting from a list of "root" containers each one expected to provide a function to return all reachable object.

Each "collectable" objects is also expected to be a container itself.

Member Typedef Documentation

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

Member Function Documentation

void gnash::GC::addCollectable ( const GcResource item  )  [inline]

Add an heap 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)
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.

References _, and gnash::GcResource::isReachable().

void gnash::GC::cleanup (  )  [static]

Delete the singleton. You'll need to call init() again after this call, if you want to use the singleton. See init(GcRoot&)

Referenced by gnash::clear().

void gnash::GC::countCollectables ( CollectablesCount count  )  const

Count collectables.

void gnash::GC::fuzzyCollect (  )  [inline]

Run the collector, if worth it.

References _.

Referenced by gnash::clear().

static GC& gnash::GC::get (  )  [inline, static]

Get the singleton.

An assertion will fail if the GC has not been initialized yet. See init(GcRoot&).

Referenced by gnash::clear().

GC & gnash::GC::init ( GcRoot r  )  [static]

Init the singleton instance using the given GcRoot.

References root.

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: