From 01b19bafb224ddd2b7cc3aef557274ffb38c9c42 Mon Sep 17 00:00:00 2001 From: Simon Mo Date: Fri, 23 Dec 2022 15:19:38 -0800 Subject: [PATCH] [Serve] Address incremental memory leak due to _PyObjScanner (#31317) --- python/ray/dag/dag_node.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/ray/dag/dag_node.py b/python/ray/dag/dag_node.py index f7a328506328..f2f615e85224 100644 --- a/python/ray/dag/dag_node.py +++ b/python/ray/dag/dag_node.py @@ -175,6 +175,7 @@ def _get_all_child_nodes(self) -> List["DAGNode"]: ): if n not in children: children.append(n) + scanner.clear() return children def _apply_and_replace_all_child_nodes( @@ -210,6 +211,7 @@ def _apply_and_replace_all_child_nodes( new_args, new_kwargs, new_other_args_to_resolve = scanner.replace_nodes( replace_table ) + scanner.clear() # Return updated copy of self. return self._copy( @@ -288,6 +290,7 @@ def apply_functional( replace_table[node] = apply_fn(node) replaced_inputs = scanner.replace_nodes(replace_table) + scanner.clear() return replaced_inputs