Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Only gc.collect() under windows
Under Windows, tempfile objects are holding references to open files
until the garbage collector closes them and frees them.  Explicit
calls to gc.collect() were added to the finalizer for the Repo class
to force them to be closed synchronously.  However, this is expensive,
especially in large, long-running programs.  As a temporary measure
to alleviate the performance regression on other platforms, only
perform these calls when running under Windows.

Fixes #553
  • Loading branch information
James E. Blair committed Oct 9, 2017
commit 454fedab8ea138057cc73aa545ecb2cf0dac5b4b
12 changes: 10 additions & 2 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,17 @@ def __del__(self):
def close(self):
if self.git:
self.git.clear_cache()
gc.collect()
# Tempfiles objects on Windows are holding references to
# open files until they are collected by the garbage
# collector, thus preventing deletion.
# TODO: Find these references and ensure they are closed
# and deleted synchronously rather than forcing a gc
# collection.
if is_win:
gc.collect()
gitdb.util.mman.collect()
gc.collect()
if is_win:
gc.collect()

def __eq__(self, rhs):
if isinstance(rhs, Repo):
Expand Down