commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7394 - trunk/gnue-common/src/apps


From: johannes
Subject: [gnue] r7394 - trunk/gnue-common/src/apps
Date: Mon, 18 Apr 2005 07:40:11 -0500 (CDT)

Author: johannes
Date: 2005-04-18 07:40:09 -0500 (Mon, 18 Apr 2005)
New Revision: 7394

Modified:
   trunk/gnue-common/src/apps/GBaseApp.py
Log:
Let the automatic gc do it's job and only debug really unreachable objects


Modified: trunk/gnue-common/src/apps/GBaseApp.py
===================================================================
--- trunk/gnue-common/src/apps/GBaseApp.py      2005-04-18 09:34:36 UTC (rev 
7393)
+++ trunk/gnue-common/src/apps/GBaseApp.py      2005-04-18 12:40:09 UTC (rev 
7394)
@@ -817,14 +817,9 @@
 
   def __installGCHandler (self):
     """
-    Enable automatic garbage collection, set it's debug-level to DEBUG_LEAK and
-    install a signal handler for SIGUSR1, which actually performs the
-    debugging.
+    Install a signal handler for SIGUSR1, which actually performs the 
debugging.
     """
 
-    gc.enable
-    gc.set_debug (gc.DEBUG_LEAK)
-
     signal.signal (signal.SIGUSR1, self.debugGarbageCollection)
 
 
@@ -846,38 +841,40 @@
 
     log = open (filename, 'w')
     try:
-      unreachable = gc.collect ()
+      # If we are interested in the objects collected by the garbage collection
+      # set the debug level to gc.DEBUG_LEAK. In this case gc.garbage contains
+      # all objects, collectable and uncollectable as well and we are able to
+      # inspect those cycles and objects. Please not to free all items in
+      # gc.garbage afterwards (i.e. del gc.garbage [:]).
+      gc.collect ()
 
-      try:
-        self.__gcLog (log, "Number of unreachable objects: %d" % unreachable)
-        self.__gcLog (log,
-                      "Items in gc.garbage sequence : %d" % len (gc.garbage))
-        self.__gcLog (log, "Dump of gc.garbage sequence:")
-        self.__gcLog (log, "-" * 70)
+      self.__gcLog (log, "Number of unreachable objects: %d" % len 
(gc.garbage))
+      if not gc.garbage:
+        return
 
-        for item in gc.garbage:
-          try:
-            itemrep = "%s: %s" % (type (item), repr (item))
-            cycle   = self.findCycle (item, item)
+      self.__gcLog (log, "Dump of gc.garbage sequence:")
+      self.__gcLog (log, "-" * 70)
 
-          except:
-            itemrep = "No representation available for object (weakref/proxy?)"
-            cycle   = None
+      for item in gc.garbage:
+        try:
+          itemrep = "%s: %s" % (type (item), repr (item))
+          cycle   = self.findCycle (item, item)
 
-          self.__gcLog (log, "%s" % itemrep)
+        except:
+          itemrep = "No representation available for object (weakref/proxy?)"
+          cycle   = None
 
-          if cycle:
-            self.__gcLog (log, "=" * 70)
+        self.__gcLog (log, "%s" % itemrep)
 
-            for line in self.analyzeCycle (cycle):
-              self.__gcLog (log, line)
+        if cycle:
+          self.__gcLog (log, "=" * 70)
 
-            self.__gcLog (log, "=" * 70)
+          for line in self.analyzeCycle (cycle):
+            self.__gcLog (log, line)
 
-        self.__gcLog (log, "-" * 70)
+          self.__gcLog (log, "=" * 70)
 
-      finally:
-        del gc.garbage [:]
+      self.__gcLog (log, "-" * 70)
 
     finally:
       log.close ()





reply via email to

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