gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11696: Fix a bug hiding beyond a GN


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11696: Fix a bug hiding beyond a GNASH_GC_DEBUG macro.
Date: Tue, 15 Dec 2009 23:39:36 +0100
User-agent: Bazaar (2.0.2)

------------------------------------------------------------
revno: 11696
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Tue 2009-12-15 23:39:36 +0100
message:
  Fix a bug hiding beyond a GNASH_GC_DEBUG macro.
  The bug prevented the count of collectables found in last run from being 
properly updated, resulting in more-then-needed scan runs (cleanUnreachable was 
always returning 0 as the count of deleted objects).
  Also simplified the skip condition to be more readable and add more checks
  when GNASH_GC_DEBUG is defined.
modified:
  libbase/GC.cpp
=== modified file 'libbase/GC.cpp'
--- a/libbase/GC.cpp    2009-02-25 22:33:03 +0000
+++ b/libbase/GC.cpp    2009-12-15 22:39:36 +0000
@@ -24,6 +24,13 @@
 #include "GC.h"
 #include "utility.h" // for typeName()
 
+#ifndef GNASH_GC_DEBUG
+// For debug level up to 1 it's enough to set it here
+// but for higher levels you'll need to touch the header file.
+// Touching this file is cheaper (won't need full rebuild)
+//# define GNASH_GC_DEBUG 1
+#endif
+
 #ifdef GNASH_GC_DEBUG
 #include "log.h"
 #endif
@@ -92,13 +99,11 @@
                const GcResource* res = *i;
                if ( ! res->isReachable() )
                {
-#ifdef GNASH_GC_DEBUG 
 #if GNASH_GC_DEBUG > 1
                        log_debug(_("GC %p: cleanUnreachable deleting object %p 
(%s)"),
                                        (void*)this, (void*)res, 
typeName(*res).c_str());
 #endif
                        ++deleted;
-#endif
                        delete res;
                        i = _resList.erase(i);
                }
@@ -108,11 +113,6 @@
                        ++i;
                }
        }
-#ifdef GNASH_GC_DEBUG 
-       log_debug(_("GC %p: cleanUnreachable deleted %d"
-                       " resources marked as unreachable"),
-                       (void*)this, deleted);
-#endif
 
        return deleted;
 }
@@ -121,7 +121,7 @@
 GC::collect()
 {
        size_t curResSize = _resList.size(); // this is O(n) on GNU stdc++ lib !
-       if ( (curResSize - _lastResCount) < maxNewCollectablesCount )
+       if ( curResSize <  _lastResCount + maxNewCollectablesCount )
        {
 #if GNASH_GC_DEBUG  > 1
                log_debug(_("Garbage collection skipped since number of 
collectables added since last run is too low (%d)"),
@@ -135,7 +135,7 @@
 #endif
 
 #ifdef GNASH_GC_DEBUG 
-       log_debug(_("GC %p Starting collector: %d collectables"), (void *)this, 
curResSize);
+       log_debug(_("GC %p Starting collector: %d collectables (from %d of last 
run)"), (void *)this, curResSize, _lastResCount);
 #endif // GNASH_GC_DEBUG
 
 #ifndef NDEBUG
@@ -146,8 +146,18 @@
        // Mark all resources as reachable
        markReachable();
 
-       // clean unreachable resources, and mark them others as reachable again
-       _lastResCount = curResSize - cleanUnreachable();
+       // clean unreachable resources, and mark the others as reachable again
+       size_t deleted = cleanUnreachable();
+
+       _lastResCount = curResSize - deleted;
+
+#ifdef GNASH_GC_DEBUG 
+       log_debug(_("GC %p: cleanUnreachable deleted %d unreachable resources, "
+            "leaving %d alive"),
+                       (void*)this, deleted, _lastResCount);
+       assert(_lastResCount == _resList.size()); // again O(n)...
+#endif
+
 }
 
 void


reply via email to

[Prev in Thread] Current Thread [Next in Thread]