Gnash  0.8.11dev
Public Types | Public Member Functions | List of all members
gnash::GC Class Reference

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. More...
 
 ~GC ()
 Destroy the collector, releasing all collectables. More...
 
void addCollectable (const GcResource *item)
 Add an object to the list of managed collectables. More...
 
void fuzzyCollect ()
 Run the collector, if worth it. More...
 
void runCycle ()
 Run the collection cycle. More...
 
void countCollectables (CollectablesCount &count) const
 Count collectables. More...
 

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

§ CollectablesCount

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

Constructor & Destructor Documentation

§ GC()

gnash::GC::GC ( GcRoot root)

Create a garbage collector using the given root.

Parameters
rootThe top level of the GC, which takes care of marking all further resources.

References gnash::log_debug().

§ ~GC()

gnash::GC::~GC ( )

Member Function Documentation

§ addCollectable()

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:

  • 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)
Parameters
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 _, gnash::GcResource::isReachable(), and gnash::log_debug().

Referenced by gnash::GcResource::GcResource().

§ countCollectables()

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

Count collectables.

References gnash::typeName().

Referenced by gnash::Gui::setInvalidatedRegions().

§ fuzzyCollect()

void gnash::GC::fuzzyCollect ( )
inline

Run the collector, if worth it.

References _, and gnash::log_debug().

Referenced by gnash::movie_root::getRegisteredClass(), and gnash::movie_root::reset().

§ runCycle()

void gnash::GC::runCycle ( )

Run the collection cycle.

Find all reachable collectables, destroy all the others.

References gnash::log_debug().


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