Class for managing garbage collection.
More...
#include <GCManager.hpp>
List of all members.
Static Public Member Functions |
static void | gc () |
| Initiate a mark-sweep garbage collection.
|
static size_t | maxBytes () |
| Maximum number of bytes used.
|
static size_t | maxNodes () |
| Maximum number of GCNode objects allocated.
|
static void | resetMaxTallies () |
| Reset the tallies of the maximum numbers of bytes and GCNode objects.
|
static void | setGCThreshold (size_t initial_threshold) |
| Enable mark-sweep garbage collection.
|
static void | setMonitors (void(*pre_gc)()=0, void(*post_gc)()=0) |
| Set/unset monitors on mark-sweep garbage collection.
|
static std::ostream * | setReporting (std::ostream *os=0) |
| Set the output stream for garbage collection reporting.
|
static void | torture (bool on) |
| Turn garbage collection torture on or off.
|
static size_t | triggerLevel () |
| Current threshold level for mark-sweep garbage collection.
|
Detailed Description
Class for managing garbage collection.
This class only has static members. A mark-sweep garbage collection can be initiated explicitly by calling GCManager::gc(). Also, GCNode::operator new() will automatically initiate a mark-sweep GC if the number of bytes allocated via CXXR::MemoryBank exceeds a threshold level supplied by GCManager::triggerLevel() This threshold value varies during the run, subject to a minimum value specified in the enableGC() method.
Member Function Documentation
Initiate a mark-sweep garbage collection.
It is currently an error to initiate a mark-sweep garbage collection while a GCNode object is under construction.
static size_t CXXR::GCManager::maxBytes |
( |
| ) |
|
|
inlinestatic |
Maximum number of bytes used.
- Returns:
- the maximum number of bytes used (up to the time of the most recent garbage collection.)
- Note:
- In CXXR, the record of the maximum number of bytes used is reviewed (and updated if necessary) only at the start of a mark-sweep garbage collection, and so will almost certainly underestimate the true maximum.
static size_t CXXR::GCManager::maxNodes |
( |
| ) |
|
|
inlinestatic |
Maximum number of GCNode objects allocated.
- Returns:
- the maximum number of GCNode objects allocated (up to the time of the most recent garbage collection.)
- Note:
- This method is provided for compatibility with CR. The number of GCNode objects doesn't directly affect the operation of garbage collection in CXXR.
-
In CXXR, the record of the maximum number of GCNode objects allocated is reviewed (and updated if necessary) only at the start of a mark-sweep garbage collection, and so will almost certainly underestimate the true maximum.
void GCManager::resetMaxTallies |
( |
| ) |
|
|
static |
Reset the tallies of the maximum numbers of bytes and GCNode objects.
This method resets the record of the maximum number of bytes allocated to the current number of bytes allocated, and similarly for the maximum number of GCNode objects.
void GCManager::setGCThreshold |
( |
size_t |
initial_threshold | ) |
|
|
static |
Enable mark-sweep garbage collection.
No automatic mark-sweep garbage collection of GCNode objects will take place until this method has been called.
- Parameters:
-
initial_threshold | Initial value for the collection threshold. The threshold will never be made less than this value during the run (or until the threshold is changed by a subsequent call to setGCThreshold() ). |
static void CXXR::GCManager::setMonitors |
( |
void(*)() |
pre_gc = 0 , |
|
|
void(*)() |
post_gc = 0 |
|
) |
| |
|
inlinestatic |
Set/unset monitors on mark-sweep garbage collection.
- Parameters:
-
pre_gc | If not a null pointer, this function will be called just before garbage collection begins, e.g. to carry out timing. It must not itself give rise to a garbage collection. |
post_gc | If not a null pointer, this function will be called just after garbage collection is completed. It must not itself give rise to a garbage collection. |
std::ostream * GCManager::setReporting |
( |
std::ostream * |
os = 0 | ) |
|
|
static |
Set the output stream for garbage collection reporting.
- Parameters:
-
os | Pointer to the output stream to which reporting should be directed. If NULL, suppresses reporting. |
- Returns:
- The previous value of the output stream pointer.
static void CXXR::GCManager::torture |
( |
bool |
on | ) |
|
|
inlinestatic |
Turn garbage collection torture on or off.
- Parameters:
-
on | The required torturing status. |
- Note:
- GC torture is no longer implemented in CXXR, so this function is a no-op.
static size_t CXXR::GCManager::triggerLevel |
( |
| ) |
|
|
inlinestatic |
Current threshold level for mark-sweep garbage collection.
- Returns:
- The current threshold level. When GCNode::operator new is on the point of requesting memory from MemoryBank, if it finds that the number of bytes already allocated via MemoryBank is at least as great as this threshold level, it may initiate a mark-sweep garbage collection.
The documentation for this class was generated from the following files: