From 1ac7b92b45f16c6404f7a3388cff0a223c3124a9 Mon Sep 17 00:00:00 2001 From: 0HyperCube <78500760+0HyperCube@users.noreply.github.com> Date: Sat, 13 Jan 2024 16:22:35 +0000 Subject: [PATCH] Fix inferred types memory leak (#1566) --- node-graph/graph-craft/src/proto.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/node-graph/graph-craft/src/proto.rs b/node-graph/graph-craft/src/proto.rs index 4fd2405e..463c7e43 100644 --- a/node-graph/graph-craft/src/proto.rs +++ b/node-graph/graph-craft/src/proto.rs @@ -648,9 +648,17 @@ impl TypingContext { /// and store them in the `inferred` field. The proto network has to be topologically sorted /// and contain fully resolved stable node ids. pub fn update(&mut self, network: &ProtoNetwork) -> Result<(), GraphErrors> { + let mut deleted_nodes = self.inferred.keys().copied().collect::>(); + for (id, node) in network.nodes.iter() { self.infer(*id, node)?; + deleted_nodes.remove(id); } + + for node in deleted_nodes { + self.inferred.remove(&node); + } + Ok(()) }