8000 ENH break cyclic memory references again · scikit-learn/scikit-learn@d242a6d · GitHub
[go: up one dir, main page]

Skip to content

Commit d242a6d

Browse files
committed
ENH break cyclic memory references again
1 parent 23531cc commit d242a6d

File tree

1 file changed

+6
-2
lines changed
  • sklearn/ensemble/_hist_gradient_boosting

1 file changed

+6
-2
lines changed

sklearn/ensemble/_hist_gradient_boosting/grower.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,9 @@ def split_next(self):
603603
smallest_child.allowed_features,
604604
)
605605
)
606+
# node.histograms is reused in largest_child.histograms. To break cyclic
607+
# memory references and help garbage collection, we set it to None.
608+
node.histograms = None
606609
self.total_compute_hist_time += time() - tic
607610

608611
tic = time()
@@ -618,8 +621,9 @@ def split_next(self):
618621
if child.is_leaf:
619622
del child.histograms
620623

621-
# We do not release the memory of node.histograms as it is reused in one of the
622-
# child nodes.
624+
# Release memory used by histograms as they are no longer needed for
625+
# internal nodes once children histograms have been computed.
626+
del node.histograms
623627

624628
return left_child_node, right_child_node
625629

0 commit comments

Comments
 (0)
0