Skip to content

Commit 20b81d4

Browse files
committed
fix(leaks, TCs): attempt to cleanup mman before deleting tmp-dirs
1 parent 47f6442 commit 20b81d4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

git/test/lib/helper.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import contextlib
99
from functools import wraps
10+
import gc
1011
import io
1112
import logging
1213
import os
@@ -18,6 +19,7 @@
1819

1920
from git.compat import string_types, is_win, PY3
2021
from git.util import rmtree, cwd
22+
import gitdb
2123

2224
import os.path as osp
2325

@@ -92,7 +94,6 @@ def wrapper(self):
9294
# a windows-only issue. In fact things should be deleted, as well as
9395
# memory maps closed, once objects go out of scope. For some reason
9496
# though this is not the case here unless we collect explicitly.
95-
import gc
9697
gc.collect()
9798
if not keep:
9899
rmtree(path)
@@ -140,9 +141,10 @@ def repo_creator(self):
140141
os.chdir(prev_cwd)
141142
rw_repo.git.clear_cache()
142143
rw_repo = None
143-
import gc
144-
gc.collect()
145144
if repo_dir is not None:
145+
gc.collect()
146+
gitdb.util.mman.collect()
147+
gc.collect()
146148
rmtree(repo_dir)
147149
# END rm test repo if possible
148150
# END cleanup
@@ -299,7 +301,8 @@ def remote_repo_creator(self):
299301
rw_daemon_repo.git.clear_cache()
300302
del rw_repo
301303
del rw_daemon_repo
302-
import gc
304+
gc.collect()
305+
gitdb.util.mman.collect()
303306
gc.collect()
304307
if rw_repo_dir:
305308
rmtree(rw_repo_dir)
@@ -350,7 +353,6 @@ def setUpClass(cls):
350353
each test type has its own repository
351354
"""
352355
from git import Repo
353-
import gc
354356
gc.collect()
355357
cls.rorepo = Repo(GIT_REPO)
356358

0 commit comments

Comments
 (0)