Fix memory leak in Index.build_graph()

`@memoize()` memory lives as long as decorated function lives, which is
permanent in this case. Since `self` is referenced as a memory key no
`Index` will ever be freed.

Changed to use `@cached_property` whose cache lives as long as the
parent instance.
This commit is contained in:
Alexander Schepanovski
2022-01-03 13:41:10 +02:00
committed by Ruslan Kuprieiev
parent 0e0e1725e6
commit 9ee428ef17
3 changed files with 11 additions and 14 deletions
+3 -1
View File
@@ -77,7 +77,9 @@ def test_locked(mocker):
def test_skip_graph_checks(tmp_dir, dvc, mocker, run_copy):
# See https://github.com/iterative/dvc/issues/2671 for more info
mock_build_graph = mocker.patch("dvc.repo.index.Index.build_graph")
from dvc.repo.index import Index
mock_build_graph = mocker.spy(Index.graph, "fget")
# sanity check
tmp_dir.gen("foo", "foo text")