Merge pull request #5172 from bk2204/cache-efficient-eviction Evict cache items more efficiently
diff --git a/src/cache.c b/src/cache.c
index 3128e40..32ba993 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -115,9 +115,12 @@ void git_cache_dispose(git_cache *cache)
/* Called with lock */
static void cache_evict_entries(git_cache *cache)
{
- size_t evict_count = 8, i;
+ size_t evict_count = git_cache_size(cache) / 2048, i;
ssize_t evicted_memory = 0;
+ if (evict_count < 8)
+ evict_count = 8;
+
/* do not infinite loop if there's not enough entries to evict */
if (evict_count > git_cache_size(cache)) {
clear_cache(cache);