commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7192 - trunk/gnue-common/src/definitions


From: johannes
Subject: [gnue] r7192 - trunk/gnue-common/src/definitions
Date: Sun, 13 Mar 2005 02:45:13 -0600 (CST)

Author: johannes
Date: 2005-03-13 02:45:12 -0600 (Sun, 13 Mar 2005)
New Revision: 7192

Modified:
   trunk/gnue-common/src/definitions/GParser.py
   trunk/gnue-common/src/definitions/GParserHelpers.py
Log:
Fixes to avoid memory leaks


Modified: trunk/gnue-common/src/definitions/GParser.py
===================================================================
--- trunk/gnue-common/src/definitions/GParser.py        2005-03-12 13:49:58 UTC 
(rev 7191)
+++ trunk/gnue-common/src/definitions/GParser.py        2005-03-13 08:45:12 UTC 
(rev 7192)
@@ -165,6 +165,9 @@
     gDebug (7, "Initializing the object tree starting at %s" %(object))
     object.phaseInit(dh._phaseInitCount)
 
+  # Break the cyclic reference in the content handler, so garbage collection is
+  # able to collect it
+  dh.parser = None
 
 
   return object

Modified: trunk/gnue-common/src/definitions/GParserHelpers.py
===================================================================
--- trunk/gnue-common/src/definitions/GParserHelpers.py 2005-03-12 13:49:58 UTC 
(rev 7191)
+++ trunk/gnue-common/src/definitions/GParserHelpers.py 2005-03-13 08:45:12 UTC 
(rev 7192)
@@ -50,6 +50,27 @@
       parent.addChild(self)
 
 
+  # ---------------------------------------------------------------------------
+  # Break up all links to the parent object
+  # ---------------------------------------------------------------------------
+
+  def unlink (self):
+    """
+    Unlink the instance from it's parent and clear the children- and
+    initialization-sequences. This function is called recursively for all child
+    elements. It breaks up cyclic references, helping the garbage collection to
+    free object trees.
+    """
+
+    self._parent = None
+
+    for child in self._children:
+      child.unlink ()
+
+    del self._children [:]
+    del self._inits [:]
+
+
 #
 # Class GContent
 #





reply via email to

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