Go to the documentation of this file.
32 #include <forward_list>
96 #if GNASH_GC_DEBUG > 2
97 log_debug(
_(
"Instance %p of class %s already reachable, "
98 "setReachable doing nothing"), (
void*)
this,
104 #if GNASH_GC_DEBUG > 2
105 log_debug(
_(
"Instance %p of class %s set to reachable, scanning "
106 "reachable resources from it"), (
void*)
this,
138 #if GNASH_GC_DEBUG > 1
139 log_debug(
_(
"Class %s didn't override the markReachableResources() "
153 mutable bool _reachable;
201 _resList.emplace_front(item); ++_resListSize;
203 #if GNASH_GC_DEBUG > 1
204 log_debug(
_(
"GC: collectable %p added, num collectables: %d"), item,
241 if (_resListSize < _lastResCount + _maxNewCollectablesCount) {
242 #if GNASH_GC_DEBUG > 1
243 log_debug(
_(
"GC: collection cycle skipped - %d/%d new resources "
244 "allocated since last run (from %d to %d)"),
245 _resListSize-_lastResCount, _maxNewCollectablesCount,
246 _lastResCount, _resListSize);
247 #endif // GNASH_GC_DEBUG
268 typedef std::forward_list<const GcResource*> ResList;
271 void markReachable() {
272 #if GNASH_GC_DEBUG > 2
273 log_debug(
_(
"GC %p: MARK SCAN"), (
void*)
this);
275 _root.markReachableResources();
281 size_t cleanUnreachable();
285 size_t _maxNewCollectablesCount;
291 ResList::size_type _resListSize;
298 ResList::size_type _lastResCount;
300 #ifdef GNASH_GC_DEBUG
301 size_t _collectorRuns;
GcResource(GC &gc)
Create a Garbage-collected resource associated with a GC.
Definition: GC.h:307
Collectable resource.
Definition: GC.h:75
~GC()
Destroy the collector, releasing all collectables.
Definition: GC.cpp:55
virtual ~GcRoot()
Definition: GC.h:68
void clearReachable() const
Clear the reachable flag.
Definition: GC.h:118
void log_debug(StringType msg, Args... args)
Definition: log.h:301
@ i
Definition: GnashKey.h:155
std::string typeName(const T &inst)
Definition: utility.h:93
void countCollectables(CollectablesCount &count) const
Count collectables.
Definition: GC.cpp:131
#define _(String)
Definition: log.h:44
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
Garbage collector singleton.
Definition: GC.h:165
std::map< std::string, unsigned int > CollectablesCount
Definition: GC.h:260
void addCollectable(const GcResource *item)
Add an object to the list of managed collectables.
Definition: GC.h:194
Abstract class to allow the GC to store "roots" into a container.
Definition: GC.h:56
void fuzzyCollect()
Run the collector, if worth it.
Definition: GC.h:210
bool isReachable() const
Return true if this object is marked as reachable.
Definition: GC.h:115
virtual ~GcResource()
Delete this resource.
Definition: GC.h:149
virtual void markReachableResources() const
Scan all GC resources reachable by this instance.
Definition: GC.h:136
virtual void markReachableResources() const =0
Scan all GC resources reachable by this instance.
void runCycle()
Run the collection cycle.
Definition: GC.cpp:103
#define DSOEXPORT
Definition: dsodefs.h:55
GC(GcRoot &root)
Create a garbage collector using the given root.
Definition: GC.cpp:34
@ e
Definition: GnashKey.h:151
void setReachable() const
Mark this resource as being reachable.
Definition: GC.h:92