[Bf-blender-cvs] [1b63c36] depsgraph_refactor: Depsgraph: Fix for memory leak with unfreed links

Joshua Leung noreply at git.blender.org
Fri Jan 2 05:15:23 CET 2015


Commit: 1b63c36ca48e2770d736e9832a19c2a7bcb019fc
Author: Joshua Leung
Date:   Fri Jan 2 16:50:58 2015 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rB1b63c36ca48e2770d736e9832a19c2a7bcb019fc

Depsgraph: Fix for memory leak with unfreed links

Now that relations are back in the base node, relations should be freed in
the destructors for DepsNode instead of OperationDepsNode.

This fixes memory leaks when using links between IDDepsNodes and also for
TimeSourceDepsNodes

===================================================================

M	source/blender/depsgraph/intern/depsnode.cpp
M	source/blender/depsgraph/intern/depsnode_operation.cpp

===================================================================

diff --git a/source/blender/depsgraph/intern/depsnode.cpp b/source/blender/depsgraph/intern/depsnode.cpp
index be576dc..35a32b4 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -63,6 +63,21 @@ DepsNode::DepsNode()
 
 DepsNode::~DepsNode()
 {
+	/* free links
+	 * note: deleting relations will remove them from the node relations set,
+	 * but only touch the same position as we are using here, which is safe.
+	 */
+	DEPSNODE_RELATIONS_ITER_BEGIN(this->inlinks, rel)
+	{
+		OBJECT_GUARDED_DELETE(rel, DepsRelation);
+	}
+	DEPSNODE_RELATIONS_ITER_END;
+	
+	DEPSNODE_RELATIONS_ITER_BEGIN(this->outlinks, rel)
+	{
+		OBJECT_GUARDED_DELETE(rel, DepsRelation);
+	}
+	DEPSNODE_RELATIONS_ITER_END;
 }
 
 
diff --git a/source/blender/depsgraph/intern/depsnode_operation.cpp b/source/blender/depsgraph/intern/depsnode_operation.cpp
index 0ffc1bc..5ebce54 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.cpp
+++ b/source/blender/depsgraph/intern/depsnode_operation.cpp
@@ -49,17 +49,6 @@ OperationDepsNode::OperationDepsNode() :
 
 OperationDepsNode::~OperationDepsNode()
 {
-	/* free links
-	 * note: deleting relations will remove them from the node relations set,
-	 * but only touch the same position as we are using here, which is safe.
-	 */
-	DEPSNODE_RELATIONS_ITER_BEGIN(this->inlinks, rel)
-		OBJECT_GUARDED_DELETE(rel, DepsRelation);
-	DEPSNODE_RELATIONS_ITER_END;
-	
-	DEPSNODE_RELATIONS_ITER_BEGIN(this->outlinks, rel)
-		OBJECT_GUARDED_DELETE(rel, DepsRelation);
-	DEPSNODE_RELATIONS_ITER_END;
 }
 
 string OperationDepsNode::identifier() const




More information about the Bf-blender-cvs mailing list