summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2006-12-24 00:47:19 -0500
committerLibravatar Junio C Hamano <junkio@cox.net>2006-12-29 11:36:45 -0800
commit97bfeb34df1aa8a1cf232278624a5a5c924ee380 (patch)
treec1591e0eac89204f6db3f2a8a8ec3b86b6c40be1 /sha1_file.c
parentDefault core.packdGitWindowSize to 1 MiB if NO_MMAP. (diff)
downloadtgif-97bfeb34df1aa8a1cf232278624a5a5c924ee380.tar.xz
Release pack windows before reporting out of memory.
If we are about to fail because this process has run out of memory we should first try to automatically control our appetite for address space by releasing enough least-recently-used pack windows to gain back enough memory such that we might actually be able to meet the current allocation request. This should help users who have fairly large repositories but are working on systems with relatively small virtual address space. Many times we see reports on the mailing list of these users running out of memory during various Git operations. Dynamically decreasing the amount of pack memory used when the demand for heap memory is increasing is an intelligent solution to this problem. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 8de8ce0a72..fb1032b0fd 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -522,6 +522,13 @@ static int unuse_one_window(struct packed_git *current)
return 0;
}
+void release_pack_memory(size_t need)
+{
+ size_t cur = pack_mapped;
+ while (need >= (cur - pack_mapped) && unuse_one_window(NULL))
+ ; /* nothing */
+}
+
void unuse_pack(struct pack_window **w_cursor)
{
struct pack_window *w = *w_cursor;